Professional Documents
Culture Documents
Option Explicit
If WScript.Arguments.length = 0 Then
Dim objShell : Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "wscript.exe", Chr(34) & _
WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1
Else
Dim WshShell, objFSO, objFile, sNow, iSvcType, iStartupType, iSvcCnt,
iPerUserSvcCnt
Dim sREGFile, sBATFile, r, b, objWMIService, colListOfServices, objService,
sSvcKey
Dim sStartState, sSvcName, sSkippedSvc
Set WshShell = CreateObject("Wscript.Shell")
Set objFSO = Wscript.CreateObject("Scripting.FilesystemObject")
Set objFile = objFSO.GetFile(WScript.ScriptFullName)
iSvcCnt=0
iPerUserSvcCnt=0
Case "system"
r.WriteLine chr(34) & "Start" & Chr(34) & "=dword:00000001"
b.WriteLine "sc.exe config " & sSvcName & " start= system"
Case "auto"
'Check if it's Automatic (Delayed start)
r.WriteLine chr(34) & "Start" & Chr(34) & "=dword:00000002"
If objService.DelayedAutoStart = True Then
r.WriteLine chr(34) & "DelayedAutostart" & Chr(34) & "=dword:00000001"
b.WriteLine "sc.exe config " & sSvcName & " start= delayed-auto"
Else
r.WriteLine chr(34) & "DelayedAutostart" & Chr(34) & "=-"
b.WriteLine "sc.exe config " & sSvcName & " start= auto"
End If
Case "manual"
Case "disabled"
'Case Else
End Select
r.WriteBlankLines 1
Next
If trim(sSkippedSvc) <> "" Then
WScript.Echo iSvcCnt & " - Total # of Services." & _
"(including " & iPerUserSvcCnt & " Per-user Services)" & _
vbCrLf & vbCrLf & "The following services could not be backed up:" & _
vbcrlf & vbCrLf & sSkippedSvc
Else
WScript.Echo iSvcCnt & " Services found " & _
"(including " & iPerUserSvcCnt & " Per-user Services)" & _
" and their startup configuration has been backed up."
End If
r.Close
b.WriteLine "@pause"
b.Close
'WshShell.Run "notepad.exe " & sREGFile
'WshShell.Run "notepad.exe " & sBATFile
Set objFSO = Nothing
Set WshShell = Nothing
End If