-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoAdminLogon.vbs
More file actions
59 lines (54 loc) · 2.27 KB
/
Copy pathAutoAdminLogon.vbs
File metadata and controls
59 lines (54 loc) · 2.27 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'------------------------------------------------------------------------
'
' An example script using WMI to set a registry value on a number of
' hosts as defined in the text file "c:\clients.txt". This particular
' registry edit prompts you to change the AutoAdminLogon value.
'
' Shawn Stugart
'========================================================================
Option Explicit
Dim strKeyPath, strValueName, sFileName, oFSO, oShell, oInputFile
Dim strComputer, oReg, sResult, vChangeValue, strValue, errReturn
Const HKEY_LOCAL_MACHINE = &H80000002
const ForReading = 1
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\"
strValueName = "AutoAdminLogon"
sFileName = "clients.txt"
On Error Resume Next
set oFSO = CreateObject("Scripting.FileSystemObject")
set oShell = CreateObject("WScript.Shell")
set oInputFile = oFSO.OpenTextFile("c:\" & sFileName, ForReading)
Do Until oInputFile.AtEndOfStream
strComputer = oInputFile.Readline
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
If Err.Number <> 0 Then
sResult = sResult & "An error has occurred on " & strComputer _
& ". You may have mistyped the computer name." & VbCrLf
Err.Clear
End If
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
sResult = sResult & strComputer & ": " & strValue & VbCrLf
Loop
vChangeValue = MsgBox(sResult & VbCrLf & VbCrLf & "Do you want to change the " _
& "AutoAdminLogon values?", vbYesNo)
sResult = ""
If vChangeValue = vbYes Then
strValue = InputBox("What value do you want to set the AutoAdminLogon " _
& "to?","0 or 1?","0")
oInputFile.Close
Set oInputFile = oFSO.OpenTextFile("c:\" & sFileName, ForReading)
Do Until oInputFile.AtEndOfStream
strComputer = oInputFile.Readline
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
If Err.Number <> 0 Then
sResult = sResult & "An error has occurred on " & strComputer _
& ". You may have mistyped the computer name." & VbCrLf
Err.Clear
Else
errReturn = oReg.SetStringValue(HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue)
End If
Loop
End If
WScript.Echo "Finished"