Commit 9b2ac2cb authored by O'Reilly Media, Inc.'s avatar O'Reilly Media, Inc.
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading

04_autoadminlogon.vbs

0 → 100644
+28 −0
Changes for 04_autoadminlogon.vbs: 28 added lines, 0 removed lines.
Original line number Diff line number Diff line
' Script to turn on automatic logon
' (c) Thomas Lee 2002
' Freely distributed!
Dim Prompt, oWSH,UserName, UserPass, UserDomain
set oWSH = WScript.CreateObject("WScript.Shell")

' get user name
Prompt = "Enter the autologon user name"
UserName = InputBox(Prompt, Title, "")

' get password
Prompt = "Enter the autologon user password for " & UserName
UserPass = InputBox(Prompt, Title, "")

' get domain
Prompt = "Enter the autologon user domain for " & UserName
Userdomain = InputBox(Prompt, Title, "")

' now set these in the registry
oWSH.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoAdminLogon","1","REG_SZ"
oWSH.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName", UserDomain, "REG_SZ" 
oWSH.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName", UserName, "REG_SZ" 
oWSH.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultPassword", UserPass, "REG_SZ"

' ensure the change is persistent!
oWSH.RegWrite "HKLM\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon\ForceAutoLogon", "1", "REG_SZ" 

' All done
+21 −0
Changes for 04_noautoadminlogon.vbs: 21 added lines, 0 removed lines.
Original line number Diff line number Diff line
' Script to remove autoadmin logon
' (c) Thomas Lee 2002
' Freely distributed!
Option Explicit
On Error Resume Next

'Declare variables
Dim Prompt, oWSH

'Set the Windows Script Host Shell 
set oWSH = WScript.CreateObject("WScript.Shell")

' delete the relevant keys
oWSH.RegDelete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoAdminLogon"
oWSH.RegDelete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName"
oWSH.RegDelete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName"
oWSH.RegDelete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultPassword"

' All done - say goodbye!
Legend = "Autoadmin removed - have a nice day!"
MyBox = MsgBox (legend, 4096, "We're Done")
+143 −0
Changes for 05_WaitForProcessCmd.vbs: 143 added lines, 0 removed lines.
Original line number Diff line number Diff line
Option Explicit
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' File:     vbsWaitForProcess.vbs
' Updated:  Nov 2002
' Version:  1.0
' Author:   Dan Thomson, myITforum.com columnist
'           I can be contacted at dethomson@hotmail.com
'
' Usage:    The command processor version must be run using cscript
'           cscript vbsWaitForProcess.vbs notepad.exe 60 S
'           or
'           The IE and Popup versions can be run with cscript or wscript
'           wscript vbsWaitForProcess.vbs notepad.exe -1
'
' Input:    Name of executable  (ex: notepad.exe)
'           Time to wait in seconds before terminating the executable
'               -1 waits indefinitely for the process to finish
'               0 terminates the process imediately
'               Any value > 0 will cause the script to wait the specified
'               amount of time in seconds before terminating the process
'           Silent mode  (S)
'
' Notes:
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

On Error Resume Next

'Define some variables
Dim strProcess
Dim intWaitTime
Dim strSilent

'Get the command line arguments
strProcess = Wscript.Arguments.Item(0)
intWaitTime = CInt(Wscript.Arguments.Item(1))
strSilent = Wscript.Arguments.Item(2)

Call WaitForProcess (strProcess, intWaitTime, strSilent)

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Function: ProcessIsRunning
'
' Purpose:  Determine if a process is running
'
' Input:    Name of process
'
' Output:   True or False depending on if the process is running
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Function ProcessIsRunning( strProcess )
    Dim colProcessList

    Set colProcessList = Getobject("Winmgmts:").Execquery _
        ("Select * from Win32_Process Where Name ='" & strProcess & "'")
    If colProcessList.Count > 0 Then
        ProcessIsRunning = True
    Else
        ProcessIsRunning = False
    End If

    Set colProcessList = Nothing
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Function: TerminateProcess
'
' Purpose:  Terminates a process
'
' Input:      Name of process
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Function ProcessTerminate( strProcess )
    Dim colProcessList, objProcess

    Set colProcessList = GetObject("Winmgmts:").ExecQuery _
        ("Select * from Win32_Process Where Name ='" & strProcess & "'")
    For Each objProcess in colProcessList
        objProcess.Terminate( )
    Next

    Set colProcessList = Nothing
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Sub: WaitForProcess
'
' Purpose:  Waits for a process
'
' Input:    Name of process
'           Wait time in seconds before termination.
'             -1 will cause the script to wait indefinitely
'             0 terminates the process imediately
'             Any value > 0 will cause the script to wait the specified
'             amount of time in seconds before terminating the process
'           Display mode.
'             Passing S will run the script silent and not show any prompts
'
' Output:   On screen status
'
' Notes:    The version echos user messages in the command window via StdOut
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub WaitForProcess( strProcess, intWaitTime, strMode )

  If ProcessIsRunning(strProcess) Then
    Dim StdOut
    Dim w : w = 0
    Dim strPrompt
    Dim intPause : intPause = 1

    If UCase(strMode) <> "S" Then
      strPrompt = "Waiting for " & strProcess & " to finish."
      Set StdOut = WScript.StdOut
      StdOut.WriteLine ""
      StdOut.Write strPrompt
    End If
    'Loop while the process is running
    Do While ProcessIsRunning(strProcess)
      'Check to see if specified # of seconds have passed before terminating
      'the process. If yes, then terminate the process
      If w >= intWaitTime AND intWaitTime >= 0 Then
        Call ProcessTerminate(strProcess)
        Exit Do
      End If
      'If not running silent, post user messages
      If UCase(strMode) <> "S" Then _
        StdOut.Write "."
      'Increment the seconds counter
      w = w + intPause
      'Pause
      Wscript.Sleep(intPause * 1000)
    Loop
    If UCase(strMode) <> "S" Then
      StdOut.WriteLine ""
      Set StdOut = Nothing
    End If
  End If
End Sub
 No newline at end of file
+165 −0
Changes for 05_WaitForProcessIE.vbs: 165 added lines, 0 removed lines.
Original line number Diff line number Diff line
Option Explicit
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' File:     vbsWaitForProcess.vbs
' Updated:  Nov 2002
' Version:  1.0
' Author:   Dan Thomson, myITforum.com columnist
'           I can be contacted at dethomson@hotmail.com
'
' Usage:    The command processor version must be run using cscript
'           cscript vbsWaitForProcess.vbs notepad.exe 60 S
'           or
'           The IE and Popup versions can be run with cscript or wscript
'           wscript vbsWaitForProcess.vbs notepad.exe -1
'
' Input:    Name of executable  (ex: notepad.exe)
'           Time to wait in seconds before terminating the executable
'               -1 waits indefinitely for the process to finish
'               0 terminates the process imediately
'               Any value > 0 will cause the script to wait the specified
'               amount of time in seconds before terminating the process
'           Silent mode  (S)
'
' Notes:
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

On Error Resume Next

'Define some variables
Dim strProcess
Dim intWaitTime
Dim strSilent

'Get the command line arguments
strProcess = Wscript.Arguments.Item(0)
intWaitTime = CInt(Wscript.Arguments.Item(1))
strSilent = Wscript.Arguments.Item(2)

Call WaitForProcess (strProcess, intWaitTime, strSilent)

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Function: ProcessIsRunning
'
' Purpose:  Determine if a process is running
'
' Input:    Name of process
'
' Output:   True or False depending on if the process is running
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Function ProcessIsRunning( strProcess )
    Dim colProcessList

    Set colProcessList = Getobject("Winmgmts:").Execquery _
        ("Select * from Win32_Process Where Name ='" & strProcess & "'")
    If colProcessList.Count > 0 Then
        ProcessIsRunning = True
    Else
        ProcessIsRunning = False
    End If

    Set colProcessList = Nothing
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Function: TerminateProcess
'
' Purpose:  Terminates a process
'
' Input:      Name of process
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Function ProcessTerminate( strProcess )
    Dim colProcessList, objProcess

    Set colProcessList = GetObject("Winmgmts:").ExecQuery _
        ("Select * from Win32_Process Where Name ='" & strProcess & "'")
    For Each objProcess in colProcessList
        objProcess.Terminate( )
    Next

    Set colProcessList = Nothing
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Sub: WaitForProcess
'
' Purpose:  Waits for a process
'
' Input:    Name of process
'           Wait time in seconds before termination.
'             -1 will cause the script to wait indefinitely
'             0 terminates the process imediately
'             Any value > 0 will cause the script to wait the specified
'             amount of time in seconds before terminating the process
'             Display mode.
'             Passing S will run the script silent and not show any prompts
'
' Output:   On screen status
'
' Notes:    This version uses Internet Explorer for user messages
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub WaitForProcess( strProcess, intWaitTime, strMode )

  If ProcessIsRunning(strProcess) Then
    Dim objIntExplorer
    Dim c : c = 0
    Dim w : w = 0
    Dim strPrompt
    Dim intPause : intPause = 1

    strPrompt = "Waiting for " & strProcess & " to finish."

    'If not running silent, create reference to objIntExplorer
    'This will be used for the user messages. Also set IE display attributes
    If UCase(strMode) <> "S" Then
      Set objIntExplorer = Wscript._
      CreateObject("InternetExplorer.Application")
      With objIntExplorer
        .Navigate "about:blank"
        .ToolBar = 0
        .Menubar = 0         ' no menu
        .StatusBar = 0
        .Width=400
        .Height = 80
        .Left = 100
        .Top = 100
        .Document.Title = "WaitForProcess"
      End With
      'Wait for IE to finish
      Do While (objIntExplorer.Busy)
          Wscript.Sleep 200
      Loop
      'Show IE
      objIntExplorer.Visible = 1
    End If
    Do While ProcessIsRunning(strProcess)
      'Check to see if specified # of seconds have passed before terminating
      'the process. If yes, then terminate the process
      If w >= intWaitTime AND intWaitTime >= 0 Then
        Call ProcessTerminate(strProcess)
        Exit Do
      End If
      If UCase(strMode) <> "S" Then
        objIntExplorer.Document.Body.InnerHTML = strPrompt & String(c, ".")
        'Increment the counter.
        'Reset the counter indicator if it's > 25 because
        'we don't want it taking up a lot of screen space.
        If c > 25 Then c = 1 Else c = c + 1
        'Increment the seconds counter
        w = w + intPause
      End If
      'Pause
      Wscript.Sleep(intPause * 1000)
    Loop
    objIntExplorer.Quit( )             ' close Internet Explorer
    Set objIntExplorer = Nothing      ' release object reference

  End If
End Sub
 No newline at end of file
+148 −0
Changes for 05_WaitForProcessPopup.vbs: 148 added lines, 0 removed lines.
Original line number Diff line number Diff line
Option Explicit
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' File:     vbsWaitForProcess.vbs
' Updated:  Nov 2002
' Version:  1.0
' Author:   Dan Thomson, myITforum.com columnist
'           I can be contacted at dethomson@hotmail.com
'
' Usage:    The command processor version must be run using cscript
'           cscript vbsWaitForProcess.vbs notepad.exe 60 S
'           or
'           The IE and Popup versions can be run with cscript or wscript
'           wscript vbsWaitForProcess.vbs notepad.exe -1
'
' Input:    Name of executable  (ex: notepad.exe)
'           Time to wait in seconds before terminating the executable
'               -1 waits indefinitely for the process to finish
'               0 terminates the process imediately
'               Any value > 0 will cause the script to wait the specified
'               amount of time in seconds before terminating the process
'           Silent mode  (S)
'
' Notes:
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

On Error Resume Next

'Define some variables
Dim strProcess
Dim intWaitTime
Dim strSilent

'Get the command line arguments
strProcess = Wscript.Arguments.Item(0)
intWaitTime = CInt(Wscript.Arguments.Item(1))
strSilent = Wscript.Arguments.Item(2)

Call WaitForProcess (strProcess, intWaitTime, strSilent)

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Function: ProcessIsRunning
'
' Purpose:  Determine if a process is running
'
' Input:    Name of process
'
' Output:   True or False depending on if the process is running
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Function ProcessIsRunning( strProcess )
    Dim colProcessList

    Set colProcessList = Getobject("Winmgmts:").Execquery _
        ("Select * from Win32_Process Where Name ='" & strProcess & "'")
    If colProcessList.Count > 0 Then
        ProcessIsRunning = True
    Else
        ProcessIsRunning = False
    End If

    Set colProcessList = Nothing
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Function: TerminateProcess
'
' Purpose:  Terminates a process
'
' Input:      Name of process
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Function ProcessTerminate( strProcess )
    Dim colProcessList, objProcess

    Set colProcessList = GetObject("Winmgmts:").ExecQuery _
        ("Select * from Win32_Process Where Name ='" & strProcess & "'")
    For Each objProcess in colProcessList
        objProcess.Terminate( )
    Next

    Set colProcessList = Nothing
End Function

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Sub: WaitForProcess
'
' Purpose:  Waits for a process
'
' Input:    Name of process
'           Wait time in seconds before termination.
'             -1 will cause the script to wait indefinitely
'             0 terminates the process imediately
'             Any value > 0 will cause the script to wait the specified ' 
'             amount of time in seconds before terminating the process
'           Display mode.
'             Passing S will run the script silent and not show any prompts
'
' Output:   On screen status
'
' Notes:    This version uses WshShell.Popup for user messages
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub WaitForProcess( strProcess, intWaitTime, strMode )

  If ProcessIsRunning(strProcess) Then
    Dim objWshShell
    Dim c : c = 0
    Dim w : w = 0
    Dim strPrompt
    Dim intPopupTimer : intPopupTimer = 2
    Dim intPause : intPause = 1

    strPrompt = "Waiting for " & strProcess & " to finish."

    'If not running silent, create reference to objWshShell
    'This will be used for the user messages
    If UCase(strMode) <> "S" Then _
      Set objWshShell = CreateObject("WScript.Shell")
    'Loop while the process is running
    Do While ProcessIsRunning(strProcess)
      'Check to see if specified # of seconds have passed before terminating
      'the process. If yes, then terminate the process
      If w >= intWaitTime AND intWaitTime >= 0 Then
        Call ProcessTerminate(strProcess)
        Exit Do
      End If
      'If not running silent, post user prompt
      If UCase(strMode) <> "S" Then
        objWshShell.Popup strPrompt & String(c, "."), intPopupTimer, _
        "WaitForProcess", 64
        'Increment the counter.
        'Reset the counter indicator if it's > 25 because
        'we don't want it taking up a lot of screen space.
        If c > 25 Then c = 1 Else c = c + 1
      End If
      'Increment the seconds counter
      w = w + intPause + intPopupTimer
      'Pause
      Wscript.Sleep(intPause * 1000)
    Loop
    Set objWshShell = Nothing
  End If
End Sub
 No newline at end of file
Loading