/build/static/layout/Breadcrumb_cap_w.png

Useful XP & Win7 Scripted Installs Tips & Tasks

I just finished building out scripted installs for our XP and Win7 installs and learned *quite* a few tricks along the way. There will most likely be some repetition of other posts (since I did pick a few things up from them), but as I'm also doing this as documentation for my own department in case anything happens to me I'd like it to be fairly complete. Regardless, hope they save someone else some time and/or frustration.
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________

Tips - Things I learned or figured out from setting up scripted installs

0) If scripted installs hang during the initialization part (i.e. before the Windows setup screens), first try deleting the Host from the Systems - Boot Actions screen, then try deploying to that computer again. If it continues hanging, rebuild the scripted install. I had this happen at times for both the XP and Win7 scripted installs, and doing this always got things working again.

1) For Win7 scripted install postinstallation tasks, be sure to get pwarme's RunOnce Converter. My postinstallation tasks were unpredicatble & unreliable until I ran across this. It basically makes the Win7 postinstalls run like they the WinXP postinstalls (i.e. more reliably) http://www.appdeploy.com/messageboards/tm.asp?m=88850

2) For Win7 scripted install postinstallation tasks using EXE/MSI files, be sure to prefix the file name with "start /wait" (in the Command Line field). An example would be "start /wait cdburn-roxio-win7.exe". This isn't *always* necessary, but doesn't hurt anything and I found it to be invaluable at times. I don't use this for any of my XP scripted install postinstallation tasks (they behaved better), but found it necessary for some applications when building out more involved scripted installs.

3) On a similar note, for Win7 scripted install postinstallation tasks using batch files, be sure to prefix the file name with "call" (in the Command Line field). An example would be "call vpnclient-win7-pptp.bat". The rest is the same as point 2. For those unfamiliar with what "call" does (as I was), itt is used to call other batch files within a batch file, without aborting the execution of the calling batch file, and using the same environment for both batch files.

4) When postinstall application installs failed, I found that at least one of these solutions would invariably work:
a) if trying to do a silent install, put the command in a batch file (rather than the Command Line field) and call the batch file
b) if that fails (or a silent install isn't available), use AutoIT to create a script to automate the install screens

5) If you don't have virtual machines available (or don't want to use them) for scripted install testing, it is very useful to create a basic scripted install with just bare drivers and Windows tweaks. Use this to test scripted application installs, creating copies as needed.

6) If you are using AutoIT in Win7 w/UAC enabled, you can quickly test the script you are working on if you have an Administrator command prompt open to the directory where you have the script (typically keep them in the same place as an application installer, if using one), compile the script (right-click on it -> compile), and then run from the command prompt. This threw me for a minute since in XP you can just run the compiled EXE straight away (same as having UAC disabled, I would assume).
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________

Tasks - Things I researched and tested until they worked

A good number of these use AutoIT scripts (http://www.autoitscript.com/site/autoit/downloads/). I just happened to hear about it from another person at last year's Konference and it sounded useful. I didn't know anything about AutoIT before I started scripted installs and I am *not* a programmer. But if you run through the first two tutorials and know how to Google (ex: AutoIT import registry key), you should be able to use it. I make no claims for these scripts, other than they work for my scripted installs. Tweaks may be necessary depending on your applications, versions and other environment variables. Same as with the scripted installs, I just kept testing and tweaking until they worked consistently for me. No specific order below, so scroll through and see if something might be useful. Even if you don't use the full AutoIT scripts, there may be commands that help get you pointed in the right direction.
_____________________________________________________________
_____________________________________________________________

1) Windows XP PPTP VPN client

This was one of my early AutoIT scripts, but it works. Be sure to supply your own VPN connection name, server address and DNS server addresses.
_____________________________________________________________

; open Network Connections screen
Run("control ncpa.cpl")
WinWaitActive("Network Connections")
; create a new connection
Send("!f")
Send("n")
WinWaitActive("New Connection Wizard")
Send("!n")
Sleep(100)
; specify connection type
Send("!o")
Sleep(100)
Send("!n")
Sleep(100)
; specify VPN connection
Send("!v")
Sleep(100)
Send("!n")
Sleep(100)
; specifiy VPN connection name
Send("Company VPN")
Send("!n")
Sleep(100)
; specify VPN server address
Send("vpn.company.com")
Send("!n")
Sleep(100)
; wizard complete, desktop shortcut
Send("!s")
Sleep(100)
Send("{ENTER}")
; open Company VPN Properties
WinWaitActive("Connect Company VPN")
Send("!o")
WinWaitActive("Company VPN Properties")
; include Windows logon domain
ControlClick("Company VPN Properties", "", "SysTabControl321", "left", 1, 75, 10)
Sleep(100)
Send("!w")
; specify DNS servers
ControlClick("Company VPN Properties", "", "SysTabControl321", "left", 1, 180, 10)
Sleep(100)
$Count = 0
While $Count < 50
$Count += 1
Sleep(50)
WEnd
ControlClick("Company VPN Properties", "", "Button4", "left", 1, 50, 10)
Sleep(100)
WinWaitActive("Internet Protocol (TCP/IP) Properties")
send("!e")
Sleep(100)
Send("192.168.1.100")
Sleep(100)
Send("{TAB}")
Send("192.168.1.101")
Sleep(100)
; close Internet Protocol (TCP/IP) Properties screen
ControlClick("Internet Protocol (TCP/IP) Properties", "", "Button8", "left", 1, 35, 10)
; close Company VPN Properties screen
WinWaitActive("Company VPN Properties")
ControlClick("Company VPN Properties", "", "Button6", "left", 1, 35, 10)
; run null VPN connection test
WinWaitActive("Connect Company VPN")
Send("!c")
Sleep(100)
WinWaitActive("Error Connecting to Company VPN")
ControlClick("Error Connecting to Company VPN", "", "Button2", "left", 1, 35, 10)
; close Network Connections screen
WinWaitActive("Network Connections")
WinClose("Network Connections")
_____________________________________________________________
_____________________________________________________________

2) Windows 7 PPTP VPN client

Some of the screens in Windows 7 don't lend themselves easily to AutoIT's WinWaitActive and ControlClick functions, so I figured out a different way. Steps below - be sure to
_____________________________________________________________

a) Create VPN connection on a Win7 PC

b) Backup (copy) rasphone.pbk from:
C:\ProgramData\Microsoft\Network\Connections\Pbk

c) Save the file in a folder named Pbk and zip it up (recommend 7zip)

d) Create a new K2000 Application - i.e. VPN Client (Win7 PPTP) and upload the zipped file

e) Browse to the postinstallation task and roll the mouse over its link to determine the folder it's using
http://k2000/post_install_task_detail?post_install_task_id=121 --> using folder "121"

f) Create a batch file withe the following (be sure to change the "121" to your folder from step e)
move C:\Kace\Applications\121\Pbk c:\ProgramData\Microsoft\Network\Connections

g) Zip the Pbk folder and batch file up together, then upload (replace) the existing zip file

h) Enter something like the following in the postinstall tasks Command Line screen
call vpnclient-win7-pptp.bat
_____________________________________________________________
_____________________________________________________________

3) Activate XP (OEM)

We're OEM here for XP. I have this running after a reboot and before my application installs (MS Office, etc) so it has time to register.
_____________________________________________________________

a) Create a batch file (called mine "xpactivate.bat") and add the following line
cscript xpactivate.vbs

b) Open Notepad, paste the following lines in and save as "xpactivate.vbs"

for each Obj in GetObject("winmgmts:{impersonationLevel=impersonate}"). _
InstancesOf ("win32_WindowsProductActivation")
if Obj.ActivationRequired <> 0 then
'If necessary, save/set proxy
Obj.ActivateOnline()
'If necessary, restore proxy
end if
next

c) Zip up both files and deploy as an application by calling the batch file in the Command Line screen
_____________________________________________________________
_____________________________________________________________

4) SSD Tweaks (Win7)

This AutoIT script makes some of the typical tweaks I make for our systems using SSDs, comments in the code should explain. Depending on your machine's drive, you may need to change the "LITEONIT..." drive name . Same for the services, you may need to change how many times DOWN is pressed to hit the Disk Defrag and Superfetch services. I didn't have any luck getting this to run consistently during postinstalls, so I have it copied to the All Users (Public) Desktop and run it manually after the scripted install finished (via right-click "Run As Administrator").
_____________________________________________________________

; Go into the SSD's properties in Device Manager, go to Policies tab and check both boxes (enable write caching & turn off Windows write cache)
ShellExecute('devmgmt.msc')
WinWaitActive("Device Manager")
ControlClick("Device Manager", "", "SysTreeView321", "left", 1, 600, 300)
Sleep(100)
Send("{DOWN 5}")
Send("{RIGHT}")
Send("{DOWN}")
Send("{ENTER}")
WinWaitActive("LITEONIT LAT-128M2S Properties")
ControlClick("LITEONIT LAT-128M2S Properties", "", "SysTabControl321", "left", 1, 73, 10)
Sleep(500)
ControlClick("LITEONIT LAT-128M2S Properties", "Turn off Windows write-cache buffer &flushing on the device", "Button6", "left", 1, 7, 6)
Sleep(100)
Send("{ENTER}")
Sleep(1000)
WinClose("Device Manager")
; disable Disk Defrag service
ShellExecute('services.msc')
WinWaitActive("Services")
Send("{TAB}")
Send("d")
Send("{DOWN 7}")
Send("{ENTER}")
WinWaitActive("Disk Defragmenter Properties (Local Computer)")
Send("!e")
Send("{DOWN 2}")
Send("{ENTER}")
; disable Superfetch service
WinWaitActive("Services")
Send("s")
Send("{DOWN 14}")
Send("{ENTER}")
WinWaitActive("Superfetch Properties (Local Computer)")
Send("!t")
Sleep(3000)
Send("!e")
Send("{DOWN 2}")
Send("{ENTER}")
Sleep(500)
Send("!fx")
Sleep(500)
Send("!fx")
; set Enable Prefetcher and Enable Superfetch reg keys to '0'
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters", "EnablePrefetcher", "REG_DWORD", "00000000")
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters", "EnableSuperfetch", "REG_DWORD", "00000000")
; delete the defrag task from Task Scheduler
RunWait(@ComSpec & " /c " & "SCHTASKS /Delete /TN \Microsoft\Windows\Defrag\ScheduledDefrag /F")
_____________________________________________________________
_____________________________________________________________

5) Profile Config (Windows XP)

As with the SSD tweaks, I copy the compiled AutoIT EXE to the Desktop and run manually after the scripted install to apply my preferences for Display Properties, Start Menu, Taskbar, Windows Explorer, Microsoft Office Picture Manager (default JPG app) and IE8.
_____________________________________________________________

; configure Display Properties
Run("control.exe desk.cpl")
WinWaitActive("Display Properties")
; select Screen Saver tab
ControlClick("Display Properties", "", "SysTabControl321", "left", 1, 80, 10)
Sleep(100)
Send("!d")
Sleep(100)
WinWaitActive("Desktop Items")
Send("!d")
Send("!m")
Send("!n")
Send("!u")
Send("{ENTER}")
; select Appearance tab
WinWaitActive("Display Properties")
ControlClick("Display Properties", "", "SysTabControl321", "left", 1, 215, 10)
Sleep(100)
Send("!e")
WinWaitActive("Effects")
Send("!s")
Send("{DOWN 2}")
Send("{ENTER}")
WinWaitActive("Display Properties")
Send("{ENTER}")
Sleep(1000)
; configure Windows Taskbar settings
Run("RunDll32.exe shell32.dll,Options_RunDLL 1")
WinWaitActive("Taskbar and Start Menu Properties")
Send("!l")
Sleep(100)
Send("!q")
Sleep(100)
; select Start Menu tab
ControlClick("Taskbar and Start Menu Properties", "", "SysTabControl321", "left", 1, 85, 10)
Sleep(100)
Send("!c")
WinWaitActive("Customize Start Menu")
; select Advanced tab
ControlClick("Customize Start Menu", "", "SysTabControl321", "left", 1, 85, 10)
Sleep(100)
; uncheck Highlight newly installed programs
Send("!n")
; Control Panel
Send("{TAB}")
Send("{DOWN 2}")
Send("{SPACE}")
; Favorites menu
Send("{DOWN 3}")
Send("{SPACE}")
; My Computer
Send("{DOWN 4}")
Send("{SPACE}")
; My Documents
Send("{DOWN 4}")
Send("{SPACE}")
; My Music
Send("{DOWN 5}")
Send("{SPACE}")
; My Network Places
Send("{DOWN}")
Send("{SPACE}")
; My Pictures
Send("{DOWN 4}")
Send("{SPACE}")
; Scroll Programs
Send("{DOWN 7}")
Send("{SPACE}")
; close screens
Send("{ENTER}")
Send("{TAB 2}")
Send("{ENTER}")
Sleep(1000)
; configure Windows Explorer
Run("explorer.exe")
WinWaitActive("My Documents")
Send("!v")
Send("{DOWN 6}")
Send("{ENTER}")
Send("!t")
Send("{DOWN 3}")
Send("{ENTER}")
WinWaitActive("Folder Options")
ControlClick("Folder Options", "", "SysTabControl321", "left", 1, 70, 11)
Sleep(100)
Send("{ENTER}")
WinWaitActive("Folder views")
Send("{ENTER}")
WinWaitActive("Folder Options")
Send("{TAB 2}")
Send("{DOWN 10}")
Send("{SPACE}")
Send("{TAB 2}")
Send("{ENTER}")
WinClose("My Documents")
Sleep(1000)
; add IE8 Desktop icon
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel", "{871C5380-42A0-1069-A2EA-08002B30309D}", "REG_DWORD", "00000000")
MouseClick("left", @DesktopWidth / 2, @DesktopHeight / 2)
Send("{F5}")
Sleep(1000)
; set Microsoft Office Picture Manager as default for JPG
ShellExecute("C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures")
WinWaitActive("Sample Pictures")
Send("{DOWN}")
Send("!fhc")
Sleep(100)
If WinActive("Windows") Then
Send("!s")
Sleep(100)
Send("{ENTER}")
Sleep(100)
EndIf
WinWaitActive("Open With")
ControlClick("Open With", "", "SysTreeView321", "left", 1, 56, 28)
Sleep(100)
Send("!a")
Sleep(100)
ControlClick("Open With", "OK", "Button4", "left", 1, 36, 11)
Sleep(100)
WinWaitActive("File Types")
Send("{ENTER}")
ProcessWait("OIS.EXE")
WinWaitActive("Microsoft Office Picture Manager")
Send("!hf")
WinWaitActive("Service Options")
Send("!n")
Sleep(100)
Send("{TAB 2}")
Send("{ENTER}")
Sleep(100)
WinClose("Microsoft Office Picture Manager")
WinClose("Sample Pictures")
Sleep(1000)
; configure IE8
; make this the last part of the profile script in case it hangs
Run("c:\Program Files\Internet Explorer\iexplore.exe")
Sleep(20000)
If WinActive("MSN.com - Windows Internet Explorer") Then
WinClose("MSN.com - Windows Internet Explorer")
Sleep(5000)
Run("c:\Program Files\Internet Explorer\iexplore.exe")
Sleep(20000)
EndIf
WinWaitActive("Set Up Windows Internet Explorer 8")
Send("!n")
Sleep(500)
; turn off Suggested Sites
Send("!o")
Send("!n")
Sleep(500)
; use Express Settings
Send("!u")
Send("!f")
Sleep(10000)
WinClose("Your browser has been upgraded - Microsoft Windows - Windows Internet Explorer")
If WinActive("Internet Explorer") Then
Send("!c")
Sleep(5000)
EndIf
; disable toolbars & add-ons
WinWaitActive("MSN.com - Windows Internet Explorer")
Sleep(5000)
Send("!vtm")
Sleep(500)
Send("!vtf")
Sleep(2000)
Send("!vt")
Sleep(100)
Send("{DOWN 4}")
Sleep(100)
Send("{ENTER}")
WinWaitActive("Disable Add-on")
Send("{ENTER}")
WinWaitActive("MSN.com - Windows Internet Explorer")
WinClose("MSN.com - Windows Internet Explorer")
_____________________________________________________________
_____________________________________________________________

6) Profile Config (Windows 7)

Same idea as last one, but for Windows 7.
_____________________________________________________________

; add Desktop Icons
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel", "{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "REG_DWORD", "00000000")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel", "{645FF040-5081-101B-9F08-00AA002F954E}", "REG_DWORD", "00000000")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel", "{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}", "REG_DWORD", "00000000")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel", "{59031a47-3f72-44a7-89c5-5595fe6b30ee}", "REG_DWORD", "00000000")
; show file extensions
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "HideFileExt", "REG_DWORD", "00000000")
MouseClick("left", @DesktopWidth / 2, @DesktopHeight / 2)
Send("{F5}")
; adjust Windows Taskbar settings
Run("RunDll32.exe shell32.dll,Options_RunDLL 1")
WinWaitActive("Taskbar and Start Menu Properties")
; select Start Menu tab
ControlClick("Taskbar and Start Menu Properties", "", "SysTabControl321", "left", 1, 81, 10)
Sleep(100)
Send("!c")
WinWaitActive("Customize Start Menu")
; Computer
Send("{DOWN 2}")
Send("{SPACE}")
; Connect To
Send("{DOWN 2}")
Send("{SPACE}")
Send("{SPACE}")
; Control Panel
Send("{DOWN 3}")
Send("{SPACE}")
; Documents
Send("{DOWN 6}")
Send("{SPACE}")
; Favorites
Send("{DOWN 7}")
Send("{SPACE}")
; Highlight newly installed programs
Send("{DOWN 6}")
Send("{SPACE}")
; Music
Send("{DOWN 5}")
Send("{SPACE}")
; Network
Send("{DOWN}")
Send("{SPACE}")
; Personal Folder
Send("{DOWN 4}")
Send("{SPACE}")
; Pictures
Send("{DOWN 4}")
Send("{SPACE}")
; Recent Items
Send("{DOWN 2}")
Send("{SPACE}")
; Run command
Send("{DOWN 5}")
Send("{SPACE}")
; close screens
Send("{ENTER}")
Send("{TAB 5}")
Send("{ENTER}")
; set Microsoft Office Picture Manager as default for JPG
ShellExecute("C:\Users\Public\Pictures\Sample Pictures")
WinWaitActive("Sample Pictures")
Send("{DOWN}")
Send("!fh")
Sleep(100)
Send("{RIGHT}")
Sleep(100)
Send("c")
WinWaitActive("Open with")
Send("m")
Sleep(100)
Send("{ENTER}")
If WinActive("Microsoft Office Activation Wizard") Then
Send("!n")
Sleep(100)
If WinActive("User Account Control") Then
Send("!y")
Sleep(100)
EndIf
Sleep(5000)
Send("!c")
Sleep(100)
EndIf
If WinActive("Welcome to Microsoft Office 2010") Then
Send("!u")
If WinActive("User Account Control") Then
Send("!y")
Sleep(100)
EndIf
EndIf
WinWaitActive("Microsoft Office 2010")
Send("!hp")
WinWaitActive("Service Options")
Send("!n")
Send("{ENTER}")
WinWaitActive("Microsoft Office 2010")
WinClose("Microsoft Office 2010")
WinClose("Sample Pictures")
; set MSN.com to IE hompage
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Start Page", "REG_SZ", "http://www.msn.com")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Default_Page_URL", "REG_SZ", "http://www.msn.com")
; disable PDF toolbar in IE9
;ShellExecute("iexplore.exe")
;WinWaitActive("MSN.com - Windows Internet Explorer")
;Send("!vt")
;Sleep(1000)
;Send("{DOWN 4}")
;Sleep(100)
;Send("{ENTER}")
;WinWaitActive("Disable add-on")
;Sleep(1000)
;Send("{ENTER}")
;WinWaitActive("MSN.com - Windows Internet Explorer")
;WinClose("MSN.com - Windows Internet Explorer")
_____________________________________________________________
_____________________________________________________________

7) Temp File Cleanup (Windows XP)

Same as last two, I copy this (as a batch file) to the Desktop and run after the scripted install. Could be slipped into a RunOnce registry key (as I'm doing with a 3rd part defrag tool), but good enough for me.
_____________________________________________________________

rmdir /S /Q "C:\Documents and Settings\Administrator\Local Settings\Temp"
md "C:\Documents and Settings\Administrator\Local Settings\Temp"
rmdir /S /Q "C:\Windows\Temp"
md "C:\Windows\Temp"
exit
_____________________________________________________________
_____________________________________________________________

8) Temp File Cleanup (Windows 7)

Same idea as 7).
_____________________________________________________________

rmdir /S /Q "C:\Users\username\AppData\Local\Temp"
md "C:\Users\username\AppData\Local\Temp"
rmdir /S /Q "C:\Windows\Temp"
md "C:\Windows\Temp"
exit
_____________________________________________________________

9) Other AutoIT Tips

Here's a few isolated AutoIT tricks I found through researching. Some of these may already be in the examples above, but including them for ease of access.
_____________________________________________________________

; click in the middle of the screen (any resolution)
MouseClick("left", @DesktopWidth / 2, @DesktopHeight / 2)
_____________________________________________________________

; force reboot
Shutdown(6)
_____________________________________________________________

; map network drive
DriveMapAdd("O:", "\\fileserver\kace", 0, "domain\username", "password")
_____________________________________________________________

; open webpage
ShellExecute("iexplore.exe", "http://intranet")
_____________________________________________________________

; disable Windows Security "Open File" prompt - XP & Win7
EnvSet("SEE_MASK_NOZONECHECKS", "1")
code you want to run
EnvSet("SEE_MASK_NOZONECHECKS", "0")
_____________________________________________________________

; run a command line command
RunWait(@ComSpec & " /c " & "SCHTASKS /Delete /TN \Microsoft\Windows\Defrag\ScheduledDefrag /F")
RunWait(@COMSPEC & " /c Dir C:\")
_____________________________________________________________

; write registry key
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel", "{871C5380-42A0-1069-A2EA-08002B30309D}", "REG_DWORD", "00000000")
_____________________________________________________________
_____________________________________________________________

Other tips I've posted before

0) Activate Office 2003 OEM during Postinstall

http://itninja.com/question/activating-office-2003-oem-during-postinstall&mpage=1&key=𕉋
_____________________________________________________________

As usual, hope that helps!

John

0 Comments   [ + ] Show comments

Answers (0)

Be the first to answer this question

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ