News:

Ryan's Free Online Tech Forum
redux.

Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - scythe944

#1
Scripts / Get SID of a user
August 13, 2020, 11:36:13 AM
Just fill in "username" and "domainname" fields, then save as vbs and run.


strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set objAccount = objWMIService.Get _
    ("Win32_UserAccount.Name='username',Domain='domainname'")
Wscript.Echo objAccount.SID
#2
Scripts / Enable Accounts
August 13, 2020, 11:35:37 AM
This is useful when you're moving a bunch of users from one domain to another, as the accounts are disabled by default (if I remember correctly).

You can then run this script on the entire OU of new users to enable them all, and assign them a password.


' Set AccountControl.vbs
' Example VBScript to enable user accounts in a named OU
' Author Guy Thomas http://computerperformance.co.uk/
' Version 1.7 - March 21st 2004
' -----------------------------------------------------------------'
Option Explicit
Dim objOU, objUser, objRootDSE
Dim strContainer, strLastUser, strDNSDomain, intCounter, intAccValue
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")
strContainer = "OU=SomeChildOU,OU=SomeOU,"
intAccValue = 512
strContainer = strContainer & strDNSDomain
set objOU =GetObject("LDAP://" & strContainer )
intCounter = 0
      For each objUser in objOU
          If objUser.class="user" then
          objUser.Put "userAccountControl", intAccValue
  objUser.SetPassword "pa$$1234"
          objUser.SetInfo
          intCounter = intCounter +1
          strLastUser = objUser.Get ("name")
          End if
       next
WScript.Echo intCounter & " Accounts Enabled. Value " _
& intAccValue
WScript.Quit

'  End of VBScript Example

#3
Scripts / Reset Home folder permissions
August 13, 2020, 11:35:05 AM
This script reads the username from active directory, matches it with the user's home folder in a directory of folders, then resets the permissions of the user's folder to give them permissions to it again.  Can be VERY useful.

'============================================================================
' VBScript Source File
' NAME: Rechten Home-Directory
' AUTHOR: Ruud van den Hooff
' WEBSITE : http://wasteil.blogspot.com
' DATE  : 19-3-2007
' COMMENT: This script changes the permissions of all the subfolders in the
' specified folders. It uses the folder name and matches this with a username
' in Active Directory. Therefore the foldername must be equal to the username.
'
' Permissions  (See CONST UsrPerm1 & UsrPerm2:
' R = Read
' C = Change (write)
' F = Full control
' P = Change Permissions (Special access)
' O = Take Ownership (Special access)
' X = EXecute (Special access)
' E = REad (Special access)
' W = Write (Special access)
' D = Delete (Special access)
'
' !!!NEEDED PROGRAMS!!!
' XCACLS.EXE
' This program is part of the Support Tools
' DOWNLOAD:
' http://support.microsoft.com/kb/892777
'
'============================================================================

' DECLARING VARIABLES
Option Explicit
DIM Commando, Counter, Domain
DIM Folder, iReturn, objFSO
DIM objShell, objSysInfo, rootFolder
DIM strFolder, strUser, SubFolders

' INSTANTIATING AN OBJECT PART1
SET objSysInfo = CreateObject("ADSystemInfo")
SET objFSO = CreateObject("Scripting.FileSystemObject")
SET objShell = wscript.createObject("wscript.shell")

' ASSIGNING VALUES TO VARIABLES
strFolder = Lcase(Inputbox(Ucase("Enter path Home folder") &VbCr &VbCr _
&"Use the following syntax:" &VbCr _
&"D:\Users\","Home-Folder","D:\Users\"))
Domain = objSysInfo.ForestDNSName & "\"

' INSTANTIATING AN OBJECT PART2
SET rootFolder = objFSO.GetFolder(strFolder)
SET SubFolders = rootFolder.SubFolders

' ASSIGNING VALUES TO CONSTANTS
' INFO: You can find the possible permissions in the comment
CONST Usr1 = "Domain Admins"
CONST UsrPerm1 = "F"
CONST UsrPerm2 = "RWC"

'================================CODE=========================================

IF objFSO.FolderExists(strFolder) THEN
FOR Each Folder In SubFolders
strUser = replace(Lcase(Folder),strFolder,"")
commando = "xcacls " &Folder &" /g ""Domain Admins"":" &UsrPerm1 _
&" """ &Domain &strUser &""":" &UsrPerm2 &" /T /C /Y"
iReturn = objShell.Run(commando)
Counter = Counter + 1
' This sleep is specially done to not overload the system with
' xcacls screens.
wscript.sleep 1500
NEXT
wscript.echo "Finished!" &VBCR &Counter &" folders are reset."
ELSE
wscript.Echo "Folder: " &Ucase(strFolder) &"  doesn't exist." &VbCr _
&"Verify the location and try again."
END IF

SET objSysInfo = NOTHING
SET objFSO = NOTHING
SET objShell = NOTHING
SET rootFolder = NOTHING
SET SubFolders = NOTHING
'=============================END=OF=CODE=====================================
wscript.quit
#4
Scripts / Clear all unused user profiles
August 13, 2020, 11:34:00 AM
Clears user profiles on computer startup   :
   ' leaves the following folders   
   ' Administrator   
   ' RM Default User   
   ' Default User   
   ' All Users   
   ' ClassMate   

Save as VBS

ON ERROR RESUME NEXT
' Clears user profiles on computer startup
' leaves the following folders
' Administrator
' RM Default User
' Default User
' All Users
' ClassMate
' Reference : http://msdn2.microsoft.com/en-us/library/9kcx47hd.aspx
dim oktodelete, fso, f, foldercollection
set fso = CreateObject("Scripting.FileSystemObject")
set f = fso.getfolder("C:\Documents and Settings")
set foldercollection = f.subfolders
for each folder in foldercollection
    oktodelete = true
    if instr(1, folder.path, "Administrator") then
        oktodelete = false
    end if
    if instr(1, folder.path, "RM Default User") then
        oktodelete = false
    end if
    if instr(1, folder.path, "Default User") then
        oktodelete = false
    end if
    if instr(1, folder.path, "All Users") then
        oktodelete = false
    end if
    if instr(1, folder.path, "ClassMate") then
        oktodelete = false
    end if
    if instr(1, folder.path, "LocalService") then
        oktodelete = false
    end if
    if instr(1, folder.path, "NetworkService") then
        oktodelete = false
    end if
    if oktodelete then
        'wscript.echo "Deleting Folder : " & folder.path
        fso.deletefolder folder.path, true
    end if
next
#5
Scripts / Disable Sticky Keys via Group Policy
August 13, 2020, 11:33:11 AM
Copy and paste into a blank .vbs file, then put in a login script in Group Policy:

'Disable Sticky Keys
Set ObjShell = Wscript.CreateObject("Wscript.Shell")
RegKey = "HKCU\Control Panel\Accessibility\Stickykeys\"
WSHShell.RegWrite regkey & "Flags","122","REG_SZ"


Or as a registry file (just save in a blank .reg file and double-click to merge into your registry)

[HKEY_CURRENT_USER\Control Panel\Accessibility\StickyKeys]
"Flags"="122"
#6
Scripts / Profile Cleanup V2
August 13, 2020, 11:32:17 AM
This script checkes in the profile folder for foldernames
' which are not corresponding with a user in Active Directory. You will be
' asked te reset the rights on the folder who doesn't have a matching
' Username.


**Please note*** - This doesn't really remove the information about the profiles from the registry.  All it does is remove the user's folder from the "Documents and Settings" folder (and all data contained within).  I haven't tested this with Vista / 7, so be very careful about this and all scripts!

I am not responsible for any damage done by this or any other script on this site!

'============================================================================
' VBScript Source File
' NAME: Rechten Home-Directory
' AUTHOR: Ruudvdh (WASTEIL)
' WEBSITE: http://wasteil.blogspot.com
' DATE  : 05-04-2007
' COMMENT: This script checkes in the profile folder for foldernames
' which are not corresponding with a user in Active Directory. You will be
' asked te reset the rights on the folder who doesn't have a matching
' Username.
'
'============================================================================

' DECLARING VARIABLES
Option Explicit
DIM answer, commando, colProcess, collection
DIM counter1, counter2, counter3
DIM Folder, FSO
DIM intReturnValue, iReturn
DIM objCommand, objConnection, objFSO
DIM objRecordSet, objRootDSE, objShell
DIM objWMIService, objProcess
DIM processrun, rootFolder
DIM strObjectName, strComputer, strFold
DIM strRootSearch, SubFolders

' INSTANTIATING AN OBJECT
SET objFSO = CreateObject("Scripting.FileSystemObject")
SET objShell = wscript.createObject("wscript.shell")
SET objRootDSE = GetObject("LDAP://RootDSE")
SET collection = CreateObject("Scripting.Dictionary")

' ASSIGNING VALUES TO CONSTANTS
CONST strObjectType =    "user"
CONST strFile1 = "C:\Windows\system32\takeown.exe"
CONST strFile2 = "C:\Program Files\Support Tools\xcacls.exe"

' ASSIGNING VALUES TO VARIABLES
strFold = Lcase(Inputbox(Ucase("Enter path profile folder") &VbCr &VbCr _
&"Use the following style:" &VbCr _
&"D:\Profiles\","Profile Folder","D:\Profiles\"))
DIM process(2)
process(1) = "takeown.exe"
process(2) = "xcacls.exe"

strRootSearch = objRootDSE.Get("RootDomainNamingContext")
strComputer = "."
counter2 = 1
counter3 = 0

'================================SUBS=========================================
' SUB-procedure for checking folder name with user in Active Directory
SUB ADcheck()
SET objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"   
SET objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"<LDAP://" & strRootSearch & ">;(&(objectCategory=" & strObjectType & ")" & _
"(samAccountName=" & strObjectName & "));samAccountName,distinguishedName;subtree"

SET objRecordSet = objCommand.Execute
IF objRecordset.RecordCount = 0 THEN
answer = MsgBox("Would you reset rights  and delete folder "_
&Ucase(strObjectName),4,"Reset rights and Delete Folder")
IF answer = 6 THEN
collection.Add counter2,strObjectName
counter2 = counter2 + 1
END IF
intReturnValue=0
ELSE
objRecordSet.MoveFirst
intReturnValue=1
END IF
objConnection.Close
END SUB

' SUB-procedure for checking running process
SUB processCHK()
DO
processrun = 0
SET objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
SET colProcess = objWMIService.ExecQuery ("Select * from Win32_Process")
FOR Each objProcess in colProcess
IF objProcess.Name = process(counter1) THEN
processrun = processrun + 1
END IF
NEXT
IF processrun > 0 THEN
wscript.sleep(5000)
END IF

SET objWMIService = nothing
SET colProcess = nothing
Loop Until processrun = 0
END SUB

' SUB-procedure for reading folder names
SUB strControl()
SET rootFolder = objFSO.GetFolder(strFold)
SET SubFolders = rootFolder.SubFolders
FOR Each Folder IN SubFolders
strObjectName = replace(Lcase(Folder),strFold,"")
CALL ADcheck()
NEXT
SET rootFolder = NOTHING
SET SubFolders = NOTHING
END SUB

SUB ResetRights()
counter3 = counter3 + 1
commando = "takeown /F " &strFold &collection.Item(counter2) &" /R /A /D Y"
iReturn = objShell.Run(commando)
counter1 = 1
CALL processCHK()

commando = "xcacls " &strFold &collection.Item(counter2) &" /g ""Domain Admins"":F /T /C /Y"
iReturn = objShell.Run(commando)
counter1 = 2
CALL processCHK()
objFSO.DeleteFolder strFold &collection.Item(counter2),TRUE
END SUB

'=============================END=OF=SUBS=====================================
'
'================================CODE=========================================

IF objFSO.FolderExists(strFold) THEN
IF objFSO.FileExists(strFile2) THEN
IF objFSO.FileExists(strFile1) THEN
CALL strControl()
FOR counter2 = 1 to collection.Count
CALL ResetRights()
NEXT
answer = MsgBox(counter3 &" Folders reset and deleted",0,"Finished")
ELSE
answer = MsgBox(strFile1 &" not found." &VbCr _
&"Press [YES] to open website to to download",4,strFile1 &" not found!")
IF answer = 6 THEN
iReturn = objShell.Run("http://www.petri.co.il/download_free_reskit_tools.htm")
END IF
END IF
ELSE
answer = MsgBox(strFile2 &" not found." &VbCr _
&"Press [YES] to open website to to download",4,strFile2 &" not found!")
IF answer = 6 THEN
iReturn = objShell.Run("http://support.microsoft.com/kb/892777")
END IF
END IF
ELSE
wscript.Echo "Folder: " &Ucase(strFold) &" doesn't exist." &VbCr _
&"Verify the location and try again."
END IF

SET objCommand = NOTHING
SET objConnection = NOTHING
SET objFSO = NOTHING
SET objRecordSet = NOTHING
SET objShell = NOTHING
SET rootFolder = NOTHING
SET SubFolders = NOTHING

'=============================END=OF=CODE=====================================
wscript.quit

#7
Scripts / Create shortcut on desktop
August 13, 2020, 11:31:13 AM
A script that puts a shortcut to MS Paint on the desktop.  Of course, this can be changed to any shortcut.


Save as a vbs and put in group policy as a login script

Option Explicit
Dim objShell, objDesktop, objLink
Dim strAppPath, strWorkDir, strIconPath

strWorkDir ="C:\windows"
strAppPath = "%SystemRoot%\system32\mspaint.exe"
strIconPath = "%SystemRoot%\system32\mspaint.exe"

Set objShell = CreateObject("WScript.Shell")
objDesktop = objShell.SpecialFolders("Desktop")
Set objLink = objShell.CreateShortcut(objDesktop & "\Paint.lnk")


objLink.Description = "Paint"
objLink.HotKey = "CTRL+SHIFT+X"
objLink.IconLocation = strIconPath
objLink.TargetPath = strAppPath
objLink.WindowStyle = 3
objLink.WorkingDirectory = strWorkDir
objLink.Save

WScript.Quit
#8
Scripts / Reset Windows Updates for WSUS clients
August 13, 2020, 11:30:06 AM
If you have a computer that was imaged without using sysprep first, or just a computer that is having problems registering itself with WSUS, this fix might help:


net stop wuauserv
cd %systemroot%\SoftwareDistribution
ren Download Download.old
net start wuauserv
net stop bits
net start bits
net stop cryptsvc
cd %systemroot%\system32
ren catroot2 catroot2old
net start cryptsvc



Copy and paste into a notepad document and save it as a ".bat" file.  Name it whatever you want and run it on the affected computer
#9
Scripts / Useful scripts
August 13, 2020, 11:28:46 AM
https://web.archive.org/web/20120819104322/http://www.cis131.com/mediawiki/index.php?title=VBScripts

Whole CRAPLOAD of useful scripts.  Hope the site never goes down! - Edit, removed from their site, but still on internet archive, just slow access.
#10
General Discussion / Wondering if it's worth it
June 06, 2017, 10:51:02 PM
Just rebuilt this site and wondering if it's even worth putting any effort into getting it back into shape with all the categories and groups and all that.  There's so many sites out there these days, it almost doesn't make sense.

However, all the other sites have advertisements and junk and this one never did and hopefully never will!

So, if you need help with a computer question or advice and for some reason you got here instead of another site, then feel free to ask.  Or, if you're a computer tech and wish to help answer someone's question then please do!

I'll take advise as to what additional categories you'd like to see created.  Just sign up and PM me.

Thanks!  :)
#11
General Discussion / Install was jacked
May 23, 2017, 02:13:17 PM
Tried to update SMF but it didn't work.  I have a backup, but some other plugins weren't working before and I didn't really want to restore the whole site and bring all the errors along with it.

decided a new, fresh start would be for the best.  Besides, no one has used this site in years anyhow.