Export (0) Print
Expand All

Scenario2.vbs

By The Scripting Guys, Microsoft Corporation

This script initiates an automated installation and configuration process for Windows XP Service Pack 2 on a local computer. Scenario2.vbs launches another script, install-local.vbs, on the local computer. This script, install-local.vbs, runonce.vbs, and the SP2 setup program must be present in the same directory on the local machine.

The credentials under which the scripts run must have administrative privileges on the computer.

The other scripts perform the following functions:

Install-local.vbs

  • Runs SP2 setup on the local computer.

  • Sets AutoAdmin and RunOnce registry entries.

  • Logs results to a text file, computername-sp2-instlog.txt.

  • Forces a reboot, after which runonce.vbs is automatically launched.

Runonce.vbs

  • Runs after machine reboots for first time, launched by the RunOnce reg entry.

  • Configures Windows Firewall to allow certain programs and open certain ports. You must edit these settings to reflect the configuration of your network.

  • Enables remote administration on Windows Firewall so that remote scripts and administrative tools can again run against this host.

  • Resets AutoAdmin and RunOnce registry entries.

  • Logs results to a text file, computername-sp2-clnuplog.txt. When run with scenario1.vbs, this script copies the log file back to the administrative workstation. So when running this script with scenario2.vbs, change to the value of the g_strRemoteFolder variable to a local folder, for example:

    
    
    g_strRemoteFolder = "c:\temp-ac\logs"
    
    
    

  • Again forces a reboot.

Further explanation of Scenario 2 and the role of each script is contained in the introduction to these scripts at http://www.microsoft.com/technet/scriptcenter/solutions/appcompat/default.mspx

Scenario2.vbs corresponds and adds functionality to RunSP.cmd, one of the scripts that ships with Application Compatibility Testing and Mitigation Guide for Windows XP Service Pack 2 and which are documented in the Appendix. You can download a Windows Installer (.msi) file that installs the Guide and its associated scripts from:

http://www.microsoft.com/downloads/details.aspx?FamilyId=9300BECF-2DEE-4772-ADD9-AD0EAF89C4A7&displaylang=en

To use the script, copy the code, paste it into Notepad, and then save the script as scenario2.vbs.To run the script, open a command prompt window to the directory of the script and type:

cscript scenario2.vbs

If the default script host on the computer is Cscript.exe, the initial "cscript" may be omitted.

Script Code



'******************************************************************************
'scenario2.vbs
'Author: Peter Costantini, the Microsoft Scripting Guys
'Date: 9/2/04
'This script is designed to run on the local computer of a non-Administrator
'user in a branch office. The user must enter the local Administrator password.
'The script runs the Windows XP SP2 setup and configuration script specified
'by strScript, which ends by rebooting the machine.
'When the machine starts up again, another script runs under administrative
'credentials and performs more configuration. The the machine reboots for a
'second time.
'All scripts and the SP2 install executable must be in the same folder.
'******************************************************************************

On Error Resume Next

'Edit path to script if necessary.
strScript = "c:\temp-ac\install.vbs"
strCmdLine = "runas /noprofile /user:%computername%\Administrator" & _
 " ""cmd.exe /k cscript " & strScript & """"

'Run script under RunAs, which gets password from user at cmd prompt.
Set WshShell = CreateObject("Wscript.Shell")
WshShell.Run strCmdLine, 9, False
If Err = 0 Then
  WScript.Echo "Started installation of Windows XP Service Pack 2 " & _
   "in a new command-prompt window." & VbCrLf & _
   "When this script finishes running it will restart the computer and " & _
   "another script will run. " & VbCrLf & _
   "After the second script ends, the computer will restart again and " & _
   "the process will be complete."
Else
  WScript.Echo "Unable to begin Service Pack 2 installation." & VbCrLf & _
   "Information for help desk: " & VbCrLf & _
   "Error number: " & Err.Number & VbCrLf & _
   "Error source: " & Err.Source & VbCrLf & _
   "Error description: " & Err.Description
End If
Err.Clear



For online peer support, join The Official Scripting Guys Forum! To provide feedback or report bugs in sample scripts, please start a new discussion on the Discussions tab for this script.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft