tharris Posted January 2, 2009 Share Posted January 2, 2009 This seems like something that should be very simple and I'm sure I will be kicking myself later for this. I have a script wrote that we run on our machines after reimaging with ghost. It goes through basic configuration of the laptop so that we don't have to do it manually. I have created a GUI where we choose if this is a new hire or existing users laptop and configure it accordingly. The script is working except when you click on one of the buttons the GUI stays open in teh background while the script runs. What I would like for it to do is close the GUI once a selction is made. Any help would be greatly appreciated. expandcollapse popup#Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=Icons\symbol.ico #AutoIt3Wrapper_outfile=Laptop Setup 1280x800.exe #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** ;Script for configuring laptop after be imaged. #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form=c:\software\kodaformdesign\forms\setup.kxf $Form1_1 = GUICreate("FedEx Freight Sales Laptop Setup", 314, 207, 193, 125) $NewHire = GUICtrlCreateButton("New Hire", 72, 32, 161, 57, 0) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $ExistingUser = GUICtrlCreateButton("Existing User", 72, 109, 161, 57, 0) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### START Koda GUI section ### Form=c:\software\kodaformdesign\forms\setup.kxf While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE ExitLoop Case $nMsg = $NewHire ;Make sure the laptop is connected. MsgBox(48, "Hook me up, Scotty", "Before proceding any farther, make sure you are connected to the network.") ;Killing Sygate so nothing bombs! Run("c:\Program Files\Symantec\SPA\smc.exe -stop") WinWait("Password...") Sleep(2000) WinActive("Password...") Send("stop.sygate") Send("{Enter}") ;Creating Outlook mail profile in cached exchange mode Run("C:\Software\misc\Outlook_Profiler\profiler.exe -i c:\Software\misc\Outlook_Profiler\NewHire.ini") ;Set Power Settings RunWait("powercfg /setactive Portable/Laptop") RunWait("powercfg /change Portable/Laptop /monitor-timeout-ac 15") RunWait("powercfg /change Portable/Laptop /monitor-timeout-dc 5") RunWait("powercfg /change Portable/Laptop /disk-timeout-ac 0") RunWait("powercfg /change Portable/Laptop /disk-timeout-dc 45") RunWait("powercfg /change Portable/Laptop /standby-timeout-ac 0") RunWait("powercfg /change Portable/Laptop /standby-timeout-dc 60") ;;;;;;;;;;Time to write some reg keys;;;;;;;; ;Turning off Windows Firewall RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\WindowsFirewall\DomainProfile", "EnableFirewall", "REG_DWORD", "00000000") RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\WindowsFirewall\StandardProfile", "EnableFirewall", "REG_DWORD", "00000000") ;Registry entries to avoid IE7's first run, phishing menus, & other Microsoft contraband RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Search Page", "REG_SZ", "http://www.google.com") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Start Page", "REG_SZ", "http://home.freight.fedex.com/") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "SearchMigrated", "REG_DWORD", "00000000") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "RunOnceHasShown", "REG_DWORD", "00000001") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "RunOnceComplete", "REG_DWORD", "00000001") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PhishingFilter", "Enabled", "REG_DWORD", "00000002") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections", "DefaultConnectionSettings", "REG_BINARY", "3c0000001b000000090000002100000077656270726f78792e68726f2e667265696768742e66656465782e636f6d3a38 30070000003c6c6f63616c3e00000000010000001a000000687474703a2f2f31302e31302e392e36312f777061642e646174 7022c94fc43fc701010000000a07802a0000000000000000") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections", "SavedLegacySettings", "REG_BINARY", "3c0000001b000000090000002100000077656270726f78792e68726f2e667265696768742e66656465782e636f6d3a38 30070000003c6c6f63616c3e00000000010000001a000000687474703a2f2f31302e31302e392e36312f777061642e646174 7022c94fc43fc701010000000a07802a0000000000000000") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable", "REG_DWORD", "0") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "AutoConfigProxy", "REG_SZ", "WININET.DLL") ;Set machine to lock after 15 minutes of inactivity RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop", "ScreenSaverIsSecure", "REG_DWORD", "1") RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop", "ScreenSaveTimeout", "REG_SZ", "900") RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop", "ScreenSaverActive", "REG_SZ", "1") RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop", "SCRNSAVE.EXE", "REG_SZ", "c:\windows\system32\logon.scr") ;Set Wallpaper RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "Wallpaper", "REG_SZ", "c:\software\misc\Default-wide.bmp") RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "WallpaperStyle", "Reg_SZ", "2") DllCall("user32", "int", "SystemParametersInfo", "int", 20, "int", 1, "str", "c:\software\misc\Default-wide.bmp", "int", 0) ; Updating McAfee Antivirus Run("C:\Progra~1\McAfee\VirusS~1\mcupdate.exe") ; Installing EDSM SplashTextOn("eDSM", "Installing eDSM, Please Wait!", 250, 50, -1, 2) RunWait("c:\Software\EDSM\EDSMR11.exe --silent --ssf: server") SplashOff() ;Install Safebeoot on laptop Run("c:\software\misc\FXFSales-Encrypt.exe", "", @SW_ENABLE) ;Starting Outlook for lazy people like myself who don't want to actually click the mouse. Run("C:\Progra~1\Micros~2\Office11\Outlook.exe") ;Cleanup before exiting FileDelete("c:\docume~1\alluse~1\desktop\Run Me First.lnk") FileDelete("c:\docume~1\alluse~1\desktop\EDSMinfo.lnk") FileDelete("c:\docume~1\alluse~1\desktop\Windows Media Player.lnk") FileDelete(@UserProfileDir & "\desktop\Windows Media Player.lnk") Sleep(3000) ;Message to reboot after Outlook updates. MsgBox(48, "Setup complete!", "The laptop has been configured for the end user." & @CRLF & "" & @CRLF & "Once Outlook finishes updating please exit and choose restart on the Safeboot install." & @CRLF & "" & @CRLF & "Once you log back in set encryption through the admin website.") WinActive("Setup complete!") Exit Case $nMsg = $ExistingUser ;Make sure the laptop is connected. MsgBox(48, "Hook me up, Scotty", "Before proceding any farther, make sure you are connected to the network.") ;Killing Sygate so nothing bombs! Run("c:\Program Files\Symantec\SPA\smc.exe -stop") WinWait("Password...") Sleep(2000) WinActive("Password...") Send("stop.sygate") Send("{Enter}") ;Creating Outlook mail profile in cached exchange mode Run("C:\Software\misc\Outlook_Profiler\profiler.exe -i c:\Software\misc\Outlook_Profiler\ExistingUser.ini") ;Set Power Settings RunWait("powercfg /setactive Portable/Laptop") RunWait("powercfg /change Portable/Laptop /monitor-timeout-ac 15") RunWait("powercfg /change Portable/Laptop /monitor-timeout-dc 5") RunWait("powercfg /change Portable/Laptop /disk-timeout-ac 0") RunWait("powercfg /change Portable/Laptop /disk-timeout-dc 45") RunWait("powercfg /change Portable/Laptop /standby-timeout-ac 0") RunWait("powercfg /change Portable/Laptop /standby-timeout-dc 60") ;;;;;;;;;;Time to write some reg keys;;;;;;;; ;Turning off Windows Firewall RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\WindowsFirewall\DomainProfile", "EnableFirewall", "REG_DWORD", "00000000") RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\WindowsFirewall\StandardProfile", "EnableFirewall", "REG_DWORD", "00000000") ;Registry entries to avoid IE7's first run, phishing menus, & other Microsoft contraband RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Search Page", "REG_SZ", "http://www.google.com") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Start Page", "REG_SZ", "http://home.freight.fedex.com/") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "SearchMigrated", "REG_DWORD", "00000000") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "RunOnceHasShown", "REG_DWORD", "00000001") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "RunOnceComplete", "REG_DWORD", "00000001") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PhishingFilter", "Enabled", "REG_DWORD", "00000002") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections", "DefaultConnectionSettings", "REG_BINARY", "3c0000001b000000090000002100000077656270726f78792e68726f2e667265696768742e66656465782e636f6d3a38 30070000003c6c6f63616c3e00000000010000001a000000687474703a2f2f31302e31302e392e36312f777061642e646174 7022c94fc43fc701010000000a07802a0000000000000000") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections", "SavedLegacySettings", "REG_BINARY", "3c0000001b000000090000002100000077656270726f78792e68726f2e667265696768742e66656465782e636f6d3a38 30070000003c6c6f63616c3e00000000010000001a000000687474703a2f2f31302e31302e392e36312f777061642e646174 7022c94fc43fc701010000000a07802a0000000000000000") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable", "REG_DWORD", "0") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "AutoConfigProxy", "REG_SZ", "WININET.DLL") ;Set machine to lock after 15 minutes of inactivity RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop", "ScreenSaverIsSecure", "REG_DWORD", "1") RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop", "ScreenSaveTimeout", "REG_SZ", "900") RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop", "ScreenSaverActive", "REG_SZ", "1") RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop", "SCRNSAVE.EXE", "REG_SZ", "c:\windows\system32\logon.scr") ;Set to Truck Wallpaper RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "Wallpaper", "REG_SZ", "c:\software\misc\Default-wide.bmp") RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "WallpaperStyle", "Reg_SZ", "2") DllCall("user32", "int", "SystemParametersInfo", "int", 20, "int", 1, "str", "c:\software\misc\Default-wide.bmp", "int", 0) ; Updating McAfee Antivirus Run("C:\Progra~1\McAfee\VirusS~1\mcupdate.exe") ; Installing EDSM SplashTextOn("eDSM", "Installing eDSM, Please Wait!", 250, 50, -1, 2) RunWait("c:\Software\EDSM\EDSMR11.exe --silent --ssf: server") SplashOff() ;Install Safebeoot on laptop Run("c:\software\misc\FXFSales-Encrypt.exe", "", @SW_ENABLE) ;Starting Outlook for lazy people like myself who don't want to actually click the mouse. Run("C:\Progra~1\Micros~2\Office11\Outlook.exe") ;Cleanup before exiting FileDelete("c:\docume~1\alluse~1\desktop\Run Me First.lnk") FileDelete("c:\docume~1\alluse~1\desktop\EDSMinfo.lnk") FileDelete("c:\docume~1\alluse~1\desktop\Windows Media Player.lnk") FileDelete(@UserProfileDir & "\desktop\Windows Media Player.lnk") Sleep(3000) ;Message to reboot after Outlook updates. MsgBox(48, "Setup complete!", "The laptop has been configured for the end user." & @CRLF & "" & @CRLF & "Once Outlook finishes updating please exit and choose restart on the Safeboot install." & @CRLF & "" & @CRLF & "Once you log back in set encryption through the admin website.") WinActive("Setup complete!") Exit ExitLoop EndSelect WEnd Link to comment Share on other sites More sharing options...
Nhardel Posted January 2, 2009 Share Posted January 2, 2009 (edited) Add GUISetState(@SW_HIDE) right after the script selects the case: Case $nMsg = $ExistingUser GUISetState(@SW_HIDE) ;Make sure the laptop is connected. MsgBox(48, "Hook me up, Scotty", "Before proceding any farther, make sure you are connected to the network.") Edited January 2, 2009 by nhardel Link to comment Share on other sites More sharing options...
tharris Posted January 2, 2009 Author Share Posted January 2, 2009 This worked. Thanks for your quick response. I knew it was something easy but I have done very little work with GUIs.......as if you couldn't tell that already.Add GUISetState(@SW_HIDE) right after the script selects the case: Case $nMsg = $ExistingUser GUISetState(@SW_HIDE) ;Make sure the laptop is connected. MsgBox(48, "Hook me up, Scotty", "Before proceding any farther, make sure you are connected to the network.") Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now