Sign in to follow this  
Followers 0
ACalcutt

INI / Script problem?

6 posts in this topic

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 file

the 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 DIR

DIM $settings = @HomeDrive & "\settings.ini"

;COPY INI FILE TO HOMEDIR DRIVE IF IT DOES NOT EXIST

IF FileExists ($settings) = 0 Then

FileCopy(@WorkingDir & "\settings.ini", $settings, 0)

ENDIF

this 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 me

I 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 systems

DIM $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_image

Run(@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)

ENDIF

ELSE

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

ENDIF

WinWaitActive("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")

ENDIF

WinWaitActive("Display Properties")

SLEEP(1000)


Andrew Calcutt

Http://www.Vistumbler.net

Http://www.TechIdiots.net

Its not an error, its a undocumented feature

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 = $logonuser1

DIM $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" )

ENDIF

ENDIF

IF $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"

ENDIF

ENDIF    ;***  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" )

ENDIF

ENDIF    ;***  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"

ENDIF

ENDIF    ;***  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")

ENDIF

ENDIF    ;***  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)

ENDIF

logon.au3

RegWrite ( "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 PROBLEM

IF $logonpass = "" Then

RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword", "REG_SZ", "" )

ENDIF

RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "ForceAutoLogon", "REG_SZ", "1" )

Edited by ACalcutt

Andrew Calcutt

Http://www.Vistumbler.net

Http://www.TechIdiots.net

Its not an error, its a undocumented feature

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by ACalcutt

Andrew Calcutt

Http://www.Vistumbler.net

Http://www.TechIdiots.net

Its not an error, its a undocumented feature

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

maybe the tabs in the ini file?

i am not going to put this in a quote to preserve the tabs

settings.ini

----------------------------------

[script_Settings]Run_GUI      =1

Admin_Username     =Administrator

Admin_Password     =

Sysprep_Username    =sysprep

Sysprep_Password    =Password1

Delete_User     =

;*** 1=RUN     0=DON'T RUN

Delete_Start_User    =1

Remove_McAfee_GUID    =0

Clean_SMS     =0

Install_McAfee     =0

Set_Visual_Settings    =0

Install_VPN     =0

Install_Office     =0

Copy_Profile     =0

Wait_Updates     =0

Defrag      =0

Run_Sysprep     =0

[OFFICE]

SUITES      =*********************

APPLICATIONS     =***********************

Add_Office_Toolbar    =1

CD_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.jpg

Specify_Image_DIR    =C:

;Delete specified image when done copying *** 1 = Yes   0 = NO ***

Del_Image     =1

[Desktop_Items]

My_Documents     =1

My_Computer     =1

My_Network_Places    =1

Internet_Explorer    =1

Enable_Desktop_Cleanup    =0

[Visual_Effects]

;*** 1 = ENABLE    0 = DISABLE ***

;Animate windows when min and maxing

AWWMAM      =0

;Fade or slide menus into view

FOSMIV      =0

;Fade or slide tooltips into view

FOSTIV      =0

;Fade out menu items after clicking

FOMIAC      =0

;Show shadows under menu

SSUM      =0

;Show shadows under mouse pointer

SSUMP      =0

;Show translucent selevtion rectangle

STSR      =0

;Show window contents while dragging

SWCWD      =0

;Slide open combo boxes  

SOCB      =0

;Slide taskbar buttons

STB      =0

;Smooth edges of screen fonts

SEOSF      =0

;Smoth-scroll list boxes

SSLB      =0

;Use a background image for each folder type

UABIFEFT     =0

;Use common task in folders

UCTIF      =0

;Use drop shadows for icon lables on desktop

UDSFILOTD     =1

;Use visual styles on windows and buttons

UVSOWAB      =0

[Taskbar]

LockTaskbar     =1

Group      =0

HideInactiveIcons    =0

[startMenu]

Classic_Menu     =1

;*** 0 = Disable Icon, 1 = Display as Link, 2 = Display as menu ***

ShowControlPanel    =2

ShowMyComputer     =2

ShowMyDocs     =1

ShowMyMusic     =1

ShowMyPics     =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 start

ShowAdminTools     =3

;******** 0 = Disable,  1 = Enable ***************

EnableDragDrop     =1

ScrollPrograms     =0

ShowHelp     =0

ShowPrinters     =1

ShowRun      =1

ShowSearch     =1

ShowSetProgramAccessAndDefaults   =0

StartMenuFavorites    =1

[Classic_Menu_Options]

DisplayAdminTools    =0

DisplayFavories     =1

DisplayLogOff     =1

DisplayRun     =1

EnableDRAGandDROP    =1

ExpandControlPanel    =1

ExpandMyDocuments    =1

ExpandMyPictures    =1

ExpandNetworkConnections   =1

ExpandPrinters     =1

ScrollPrograms     =0

UsePersonalizedMenus    =0

Edited by ACalcutt

Andrew Calcutt

Http://www.Vistumbler.net

Http://www.TechIdiots.net

Its not an error, its a undocumented feature

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Well...it seems to be a problem finding the file...or maybe the file name...because on the background i set it

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

i 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 it

And 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 specified

File:McAffee\Setup.exe

Errorcode: 3.772.03.1.2302

Please 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 by ACalcutt

Andrew Calcutt

Http://www.Vistumbler.net

Http://www.TechIdiots.net

Its not an error, its a undocumented feature

Share this post


Link to post
Share on other sites

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 path

Ex.

;BEFORE

Dim $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

;NOW

Dim $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_image

If 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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0