ACalcutt Posted August 10, 2005 Share Posted August 10, 2005 I am making a script to get a pc ready for sysprep by installing the software and changing windows setttings.... the program uses an INI filethe autoit scipt and all install files are located on a cd...the script first check to see if settings.ini is on the c: drive....if not it copies it to that DIRDIM $settings = @HomeDrive & "\settings.ini";COPY INI FILE TO HOMEDIR DRIVE IF IT DOES NOT EXISTIF FileExists ($settings) = 0 ThenFileCopy(@WorkingDir & "\settings.ini", $settings, 0)ENDIFthis seems to work fine...but when my script restarts or logs off it seems to have problems with the settings. for example...part of my script changes the backround..but after a restart it does not like to type the full path...if i close the autoit program and restart it it works fine...in the background example i am getting C:\Windows\web\Wallpaper\....but it should be C:\Windows\web\Wallpaper\Desktop1.jpg ....this script works fine if the computer doesn't restart/logoff....its only when a previous item restarts the script...and if i close the script and restart again(the program is made to start where it left off) it works fine... It seems with a problem reading the ini file....but the program also keeps what it has already done in the ini so it knows what the next step is....so its a weird problem to meI also had a strange problem that makes me think maybe its something with the cdrom...mcafee setup started and then told me it could not find a file....(again after a reboot)...then i closed and restared the script and it went fine...This problem has occured on my test computer at home and my test computer at work...2 completely different systemsDIM $system_image = ""DIM $cd_image = IniRead($settings, "Background", "CD_Image", "")DIM $specified_image = IniRead($settings, "Background", "Specify_Image_Name", "")DIM $specified_image_dir = IniRead($settings, "Background", "Specify_Image_DIR", "")DIM $specified_fullpath = $specified_image_dir & "\" & $specified_imageRun(@comspec & ' /c ' & 'desk.cpl')WinWaitActive("Display Properties")WHILE 1 If WinExists("Display Properties", "Desktop") = 1 Then EXITLOOP ENDIF If WinExists("Display Properties", "Desktop") = 0 Then WinWaitActive("Display Properties") Send("^{TAB}") ENDIF SLEEP(500)WEND;------------------------------------------------Set Background-------------------------------------ControlClick("Display Properties", "", "Button1")IF FileExists ($specified_fullpath) THEN $system_image = @WindowsDir & "\web\Wallpaper\" & $specified_image SLEEP(1000) FileCopy($specified_fullpath, $system_image, 1) IF IniRead($settings, "Background", "Del_Image", "0") = "1" THEN FileDelete($specified_fullpath) ENDIFELSE IF FileExists ($cd_image) THEN $system_image = @WindowsDir & "\web\Wallpaper\" & $cd_image FileCopy ( $cd_image, $system_image, 1) ELSE msgbox(0,"Error","No Background Image Found") ENDIFENDIFWinWaitActive("Browse")IF $system_image <> "" THEN WinWaitActive("Browse") ;ControlSetText("Browse", "", "Edit1", $system_image) WHILE 1 ControlFocus ( "Browse", "", "Edit1" ) Send($system_image) IF ControlGetText ( "Browse", "", "Edit1" ) <> "" THEN ExitLOOP ENDIF WEND ControlClick("Browse", "", "Button2")ELSE WinClose("Browse")ENDIFWinWaitActive("Display Properties")SLEEP(1000) Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
ACalcutt Posted August 10, 2005 Author Share Posted August 10, 2005 (edited) Here is the main EXE script.....; ----------------------------------------------------------------------------; AutoIt Version: 3.1.0; Author:Andrew Calcutt Date:08/09/2005; Script Function: Auto-Sysprep Utility;-----------------------------------------------------------------------------;-----------------------------------------------------------------------------DIM $settings = @HomeDrive & "\settings.ini"IF FileExists ($settings) = 0 Then FileCopy(@WorkingDir & "\settings.ini", $settings, 0) FileSetAttrib ( $settings, "-R+N")ENDIF;-----------------------------------------------------------------------------;-----------------------------------------------------------------------------DIM $shutdown="RUN"DIM $logonuser1 = IniRead ($settings, "Script_Settings", "Admin_Username", "" ) DIM $logonpass1 = IniRead ($settings, "Script_Settings", "Admin_Password", "" )DIM $logonuser2 = IniRead ($settings, "Script_Settings", "Sysprep_Username", "" ) DIM $logonpass2 = IniRead ($settings, "Script_Settings", "Sysprep_Password", "" )DIM $logonuser = $logonuser1DIM $logonpass = $logonpass1;-----------------------------------------------------------------------------;-----------------------------------------------------------------------------;*** RUN GUI ***IF IniRead($settings, "Script_Settings", "Run_GUI", "1") = 1 THEN #include <gui.au3>ENDIF ;*** COPY USERNAME OF INITIAL XP USER(IF NOT ADMIN ACCOUNT) ***IF IniRead ($settings, "Script_Settings", "Delete_Start_User", "0" ) = 1 THEN IF @UserName <> $logonuser1 then IniWrite ( $settings, "Script_Settings", "Delete_User", @Username ) IniWrite ( $settings, "Script_Settings", "Delete_Start_User", "2" ) $shutdown = "LOGOFF" ELSE IniWrite ( $settings, "Script_Settings", "Delete_Start_User", "0" ) ENDIFENDIFIF $shutdown = "RUN" THEN ;*** RUN START ***;*** DELETE INITIAL USER ***IF IniRead ($settings, "Script_Settings", "Delete_Start_User", "0" ) = 2 THEN $profileuser = IniRead ($settings, "Script_Settings", "Delete_User", "" ) #include <remove_profile.au3> $logonuser = IniRead ($settings, "Script_Settings", "Delete_User", "" ) #include <remove_user.au3> $logonuser = $logonuser1 IniWrite ( $settings, "Script_Settings", "Delete_Start_User", "0" )ENDIF;*** INSTALL MCAFEE ***IF IniRead ($settings, "Script_Settings", "Install_McAfee", "0" ) = 1 THEN #include <mcafee.au3> IniWrite ( $settings, "Script_Settings", "Install_McAfee", "2" ) $shutdown = "REBOOT"ENDIF ;*** INSTALL VPN SOFTWARE ***IF IniRead ($settings, "Script_Settings", "Install_VPN", "0" ) = 1 THEN #include <vpn.au3> IniWrite ( $settings, "Script_Settings", "Install_VPN", "2" ) $shutdown = "REBOOT"ENDIF;*** INSTALL OFFICE ***IF IniRead ($settings, "Script_Settings", "Install_Office", "0" ) = 1 THEN ;#include <office.au3> #include <Auto_Install_Office.au3> IniWrite ( $settings, "Script_Settings", "Install_Office", "2" ) $shutdown = "REBOOT"ENDIFENDIF ;*** RUN END ***IF $shutdown = "RUN" THEN ;*** RUN START ***;*** SET VISUAL SETTINGS ***IF IniRead ($settings, "Script_Settings", "Set_Visual_Settings", "0" ) = 1 THEN #include <vis_settings.au3> IF IniRead ($settings, "Script_Settings", "Install_Office", "0" ) = 2 THEN IF IniRead ($settings, "OFFICE", "Add_Office_Toolbar", "0" ) = 1 THEN $toolbardir=@ProgramsCommonDir & "\Microsoft Office" #include <toolbar.au3> ENDIF ENDIF #include <desktop.au3> $regsearchstart = "My Computer\HKEY_USERS" $regsearch = "S-1-5-21" #include <findreg.au3> $HKUS1521 = ClipGet ( ) #include <Start_Menu.au3> #include <taskbar.au3> ProcessClose("explorer.exe") Run("explorer.exe") IniWrite ( $settings, "Script_Settings", "Set_Visual_Settings", "2" ) ENDIFENDIF ;*** RUN END ***IF $shutdown = "RUN" THEN ;*** RUN START ***;*** MAKE SYSPREP USER - RESTART FOR COPY PROFILE ***IF IniRead ($settings, "Script_Settings", "Copy_Profile", "0" ) = 1 THEN $logonuser = $logonuser2 $logonpass = $logonpass2 #include <new_user.au3> IniWrite ( $settings, "Script_Settings", "Copy_Profile", "2" ) $shutdown = "LOGOFF" ENDIF ENDIF ;*** RUN END ***IF $shutdown = "RUN" THEN ;*** RUN START ***;*** COPY PROFILE ***IF IniRead ($settings, "Script_Settings", "Copy_Profile", "0" ) = 2 THEN $profileuser = $logonuser1 #include <copy_profile.au3> $logonuser = $logonuser1 $logonpass = $logonpass1 IniWrite ( $settings, "Script_Settings", "Copy_Profile", "3" ) $shutdown = "LOGOFF"ENDIFENDIF ;*** RUN END ***IF $shutdown = "RUN" THEN ;*** RUN START ***;*** Remove sysprep user/profile ***IF IniRead ($settings, "Script_Settings", "Copy_Profile", "0" ) = 3 THEN $profileuser = $logonuser2 #include <remove_profile.au3> $logonuser = $logonuser2 $logonpass = $logonpass2 #include <remove_user.au3> IniWrite ( $settings, "Script_Settings", "Copy_Profile", "2" )ENDIF;*** WAIT FOR UPDATES/INSTALLS ***IF IniRead ($settings, "Script_Settings", "Wait_Updates", "0" ) = 1 THEN msgbox(0,"Waiting", "Install updates or extra software - HIT OK WHEN DONE - This window will start on next boot if you need to restart")ENDIF ;*** CLEAN SMS ***IF IniRead ($settings, "Script_Settings", "Clean_SMS", "0" ) = 1 THEN #include <clean_sms.au3> IniWrite ( $settings, "Script_Settings", "Clean_SMS", "2" )ENDIF ;*** REMOVE McAfee GUID ***IF IniRead ($settings, "Script_Settings", "Remove_McAfee_GUID", "0" ) = 1 THEN RunWait("net stop McAfeeFramework") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\ePolicy Orchestrator\Agent", "TestKeyAgentGUID") IniWrite ( $settings, "Script_Settings", "Remove_McAfee_GUID", "2" )ENDIF ;*** DEFRAGMENT ***IF IniRead ($settings, "Script_Settings", "Defrag", "0" ) = 1 THEN #include <defrag.au3> IniWrite ( $settings, "Script_Settings", "Defrag", "2" )ENDIF ;*** SYSPREP *** IF IniRead ($settings, "Script_Settings", "Run_Sysprep", "0" ) = 1 THEN FileDelete ($settings) RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Continue_Sysprep") IF @OSVersion = "WIN_XP" THEN DirCopy ( "sysprep\WinXP\sysprep", "c:\sysprep" , 1 ) ENDIF IF @OSVersion = "WIN_2000" THEN DirCopy ( "sysprep\Win2K\sysprep", "c:\sysprep" , 1 ) ENDIF Run("c:\sysprep\sysprep.exe")ENDIFENDIF ;*** RUN END ***;-----------------------------------------------------------------------------;************************************SHUTDOWN*********************************;-----------------------------------------------------------------------------;*** LOGOFF ***IF $shutdown = "LOGOFF" THEN RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Continue_Sysprep", "REG_SZ", @AutoItExe) #include <logon.au3> Shutdown (0)ENDIF;*** REBOOT ***IF $shutdown = "REBOOT" THEN RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Continue_Sysprep", "REG_SZ", @AutoItExe) #include <logon.au3> Shutdown (2)ENDIFlogon.au3RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon", "REG_SZ", "1" )RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName", "REG_SZ", $logonuser )RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword", "REG_SZ", $logonpass );FIX NO PASSWORD PROBLEMIF $logonpass = "" Then RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword", "REG_SZ", "" )ENDIFRegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "ForceAutoLogon", "REG_SZ", "1" ) Edited August 10, 2005 by ACalcutt Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
ACalcutt Posted August 10, 2005 Author Share Posted August 10, 2005 (edited) IF anyone wants the full script i will have to email it...i dont have a site to post it...and it is to big to post here....i can post sections of it if you want to see in the actuall ini I have all the variables tabed out so they are lined up Edited August 10, 2005 by ACalcutt Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
ACalcutt Posted August 10, 2005 Author Share Posted August 10, 2005 (edited) maybe the tabs in the ini file?i am not going to put this in a quote to preserve the tabssettings.ini----------------------------------[script_Settings]Run_GUI =1Admin_Username =AdministratorAdmin_Password =Sysprep_Username =sysprepSysprep_Password =Password1Delete_User =;*** 1=RUN 0=DON'T RUNDelete_Start_User =1Remove_McAfee_GUID =0Clean_SMS =0Install_McAfee =0Set_Visual_Settings =0Install_VPN =0Install_Office =0Copy_Profile =0Wait_Updates =0Defrag =0Run_Sysprep =0[OFFICE]SUITES =*********************APPLICATIONS =***********************Add_Office_Toolbar =1CD_Image =Desktop1.JPG;Specify Alternate Image below - No trailing "\" on the DIR (If image does not exist the CD_image is used)Specify_Image_Name =Desktop.jpgSpecify_Image_DIR =C:;Delete specified image when done copying *** 1 = Yes 0 = NO ***Del_Image =1[Desktop_Items]My_Documents =1My_Computer =1My_Network_Places =1Internet_Explorer =1Enable_Desktop_Cleanup =0[Visual_Effects];*** 1 = ENABLE 0 = DISABLE ***;Animate windows when min and maxingAWWMAM =0;Fade or slide menus into viewFOSMIV =0 ;Fade or slide tooltips into viewFOSTIV =0 ;Fade out menu items after clickingFOMIAC =0 ;Show shadows under menuSSUM =0 ;Show shadows under mouse pointerSSUMP =0 ;Show translucent selevtion rectangleSTSR =0 ;Show window contents while draggingSWCWD =0 ;Slide open combo boxes SOCB =0 ;Slide taskbar buttonsSTB =0;Smooth edges of screen fontsSEOSF =0 ;Smoth-scroll list boxesSSLB =0;Use a background image for each folder typeUABIFEFT =0;Use common task in foldersUCTIF =0 ;Use drop shadows for icon lables on desktopUDSFILOTD =1 ;Use visual styles on windows and buttonsUVSOWAB =0[Taskbar]LockTaskbar =1 Group =0HideInactiveIcons =0[startMenu]Classic_Menu =1;*** 0 = Disable Icon, 1 = Display as Link, 2 = Display as menu ***ShowControlPanel =2ShowMyComputer =2ShowMyDocs =1ShowMyMusic =1ShowMyPics =1;*** 0 = Disable Icon, 1 = Link to network connection folder, 2 = Display as connections menu***ShowNetConn =2;*** 0 = Disable Icon, 1 = Display in Programs, 2 = Display in programs and start, 3 = display in startShowAdminTools =3;******** 0 = Disable, 1 = Enable ***************EnableDragDrop =1ScrollPrograms =0ShowHelp =0ShowPrinters =1ShowRun =1ShowSearch =1ShowSetProgramAccessAndDefaults =0StartMenuFavorites =1[Classic_Menu_Options]DisplayAdminTools =0DisplayFavories =1DisplayLogOff =1DisplayRun =1EnableDRAGandDROP =1ExpandControlPanel =1ExpandMyDocuments =1ExpandMyPictures =1ExpandNetworkConnections =1ExpandPrinters =1ScrollPrograms =0UsePersonalizedMenus =0 Edited August 10, 2005 by ACalcutt Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
ACalcutt Posted August 11, 2005 Author Share Posted August 11, 2005 (edited) Well...it seems to be a problem finding the file...or maybe the file name...because on the background i set itIF FileExists ($cd_image) THEN $system_image = @WindowsDir & "\web\Wallpaper\" & $cd_image FileCopy ( $cd_image, $system_image, 1)ELSE msgbox(0,"Error","No Background Image Found")ENDIFi got rid of the ini default value for $cd_image...so now i am getting "No Background Image Found"....which means its must not be getting the filename from the ini file right?....but it is also using the ini file to run the program...so i dont get itAnd the McAfee problem seems even stranger to me... i get a "Netopsystems FEAD® 2.3 Optimizer" window(McAffee installer)...it gives me this"The system cannot find the path specifiedFile:McAffee\Setup.exeErrorcode: 3.772.03.1.2302Please send the error code to nai@netopsystems.com"now the thing i find weird about this error is that it is running McAffee\Setup.exe....because its the mcaffe installer giving me this error...Anybody at all that can help me? Edited August 11, 2005 by ACalcutt Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
ACalcutt Posted August 12, 2005 Author Share Posted August 12, 2005 OK....i figured out what was going on...i was just putting the filenames and not the directories....this worked fine untill the script logged off and started again... then it could not find the files....i fixed it just by adding the full pathEx. ;BEFOREDim $settings = @HomeDrive & "\settings.ini"Dim $cd_image = IniRead($settings, "Background", "CD_Image", "")If FileExists($cd_image) Then $system_image = @WindowsDir & "\web\Wallpaper\" & $cd_image FileCopy($cd_image, $system_image, 1)Else MsgBox(0, "Error", "No Background Image Found")EndIf;NOWDim $settings = @HomeDrive & "\settings.ini"Dim $workingdir = IniRead($settings, "Script_Settings", "Working_DIR", "")Dim $cd_image = IniRead($settings, "Background", "CD_Image", "")Dim $cd_image_fullpath = $workingdir & $cd_imageIf FileExists($cd_image_fullpath) Then $system_image = @WindowsDir & "\web\Wallpaper\" & $cd_image FileCopy($cd_image_fullpath, $system_image, 1)Else MsgBox(0, "Error", "No Background Image Found")EndIf Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature 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