forked from brianfgonzalez/Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImportREGToAllUserHives.vbs
38 lines (35 loc) · 3.19 KB
/
ImportREGToAllUserHives.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'==========================================================================
'
' NAME: ImportREGToAllUserHives.vbs
'
' AUTHOR: Brian Gonzalez
' DATE : 8/21/2013
'
' COMMENT:
'
'==========================================================================
On Error Resume Next
'Setup Objects and Constants
Const cForReading = 1, cForWriting = 2, cForAppending = 8
sScriptVersion = "08.21.2013"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = WScript.CreateObject("WScript.Shell")
Set oNetwork = createobject("Wscript.Network")
Set oReg = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\.\root\default:StdRegProv")
sScriptFolPath = oFSO.GetParentFolderName(Wscript.ScriptFullName) 'No trailing backslash
sLogFilePath = sScriptFolPath & "\ImportREGToAllUserHives.log"
'Main Execution section of script
'==========================================================================
Set oLogFile = oFSO.OpenTextFile(sLogFilePath, cForWriting, True)
oLogFile.WriteLine "ImportREGToAllUserHives script (v" & sScriptVersion & ") has begun on " & Date
Dim sUserHiveFolPath : sUserHiveFolPath = "C:\Users"
For Each oSDir In oFSO.GetFolder(sUserHiveFolPath).SubFolders
Select Case oSDir.Name
Case "Administrator", "Public", "Default User", "All Users"
Case Else
oShell.Run "%ComSpec% /c reg.exe load HKU\Temp """ & oSDir.Path & "\NTUser.DAT""", 1, True
oShell.Run "%ComSpec% /c reg.exe import """ & sScriptFolPath & "\Import.REG""", 1, True
oShell.Run "%ComSpec% /c reg.exe unload HKU\Temp"
End Select
Next
oLogFile.WriteLine "ImportREGToAllUserHives script has completed."