Jump to content

Best Approach


Recommended Posts

I have a process in which I image a server, run Newsid (UID software), reboot, change the server name, reboot, add server to the domain, reboot, lauch an automated software installation.

Can someone assist me in the right direction how how to utilize Autoit for this?

Does Autoit have the ability to have something like a master script that runs each time the server is started and call a sub script of sorts? I was thinking the sub script could add to the master script counter and then run and reboot when complete. When the server booted up the next time the master script would read the counter, seeing it has incremented and then run the next script.

Any insight appreciated.

Thanks,

Kerry

Link to comment
Share on other sites

I have a process in which I image a server, run Newsid (UID software), reboot, change the server name, reboot, add server to the domain, reboot, lauch an automated software installation.

Can someone assist me in the right direction how how to utilize Autoit for this?

Does Autoit have the ability to have something like a master script that runs each time the server is started and call a sub script of sorts? I was thinking the sub script could add to the master script counter and then run and reboot when complete. When the server booted up the next time the master script would read the counter, seeing it has incremented and then run the next script.

Any insight appreciated.

Thanks,

Kerry

yes you can run a script from another script, your best bet is to compile the sub script and call it from the main via Run() or for this case i'd go with RunWait(). then have a file that's read in by the master, and updated by the sub scripts. that way you could have your main script be like:

While 1
    $scriptnum = Number(StringStripWS(FileReadLine("test.txt")))
    Select
    Case $scriptnum = 1
        RunWait("Script1.exe")
    Case $scriptnum = 2
        RunWait("Script2.exe")
    Case $scriptnum = 3
        RunWait("Script3.exe")
    EndSelect
    Sleep(1000)
WEnd
Link to comment
Share on other sites

script1

script2

script3

script4

If script1 runs without error,

have it set the registry key RunOnce with a path to script2

then have script1 restart the system.

If script2 runs without error,

have it set the registry key RunOnce with a path to script3

then have script2 restart the system

... and so on.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

yes you can run a script from another script, your best bet is to compile the sub script and call it from the main via Run() or for this case i'd go with RunWait(). then have a file that's read in by the master, and updated by the sub scripts. that way you could have your main script be like:

While 1
    $scriptnum = Number(StringStripWS(FileReadLine("test.txt")))
    Select
    Case $scriptnum = 1
        RunWait("Script1.exe")
    Case $scriptnum = 2
        RunWait("Script2.exe")
    Case $scriptnum = 3
        RunWait("Script3.exe")
    EndSelect
    Sleep(1000)
WEnd
You're going to be so sorry you answered my first question :P

Ok, I understand the logic, but am very new to autoit and how to code it. From what you have coded above you state that the master script reads in a variable = number, how in my sub scripts do I increment the master number.

Honestly, I truely appreciate the assistance. This is going to save me a ton of time.

Thanks,

Kerry

Link to comment
Share on other sites

script1

script2

script3

script4

If script1 runs without error,

have it set the registry key RunOnce with a path to script2

then have script1 restart the system.

If script2 runs without error,

have it set the registry key RunOnce with a path to script3

then have script2 restart the system

... and so on.

Wow, you guys have some great ideas! I am not very familiar with RunOnce - does it execute only after a user has logged in or as a service?

Please advise.

Thanks,

Kerry

Link to comment
Share on other sites

You're going to be so sorry you answered my first question :P

Ok, I understand the logic, but am very new to autoit and how to code it. From what you have coded above you state that the master script reads in a variable = number, how in my sub scripts do I increment the master number.

Honestly, I truely appreciate the assistance. This is going to save me a ton of time.

Thanks,

Kerry

NP, glad to help. your subscripts would just have to have a little piece like this at the end, setting the number in the file. also i just suggested a plain file for simplicity, but you could let the master script know which have run already any number of ways, registry settings, .ini file, etc.

$output = FileOpen("test.txt",2);this opens the file to overwrite the current contents of the file
FileWriteLine($output,"1");this writes the number to the file
FileClose($output);this closes the file
Link to comment
Share on other sites

Wow, you guys have some great ideas! I am not very familiar with RunOnce - does it execute only after a user has logged in or as a service?

Please advise.

Thanks,

Kerry

These keys work after a user has logged on.

I'm not sure which OS you are setting up? W2k server, W2003 server,...

I've done this type of thing with multiple scripts and W2k server - see here for more info:

http://support.microsoft.com/kb/137367/EN-US/

I've never worked with W2003 server, but I looked into that info also:

http://support.microsoft.com/kb/314866/EN-US/

and learned that MS suggests

A program run from any of these keys should not write to the key during its execution. Doing so will interfere with the execution of other programs registered under the key.

Perhaps this also applies to the W2k server OS and I just got lucky. So, having rambled thru all of that, I would stay away from the RunOnce keys...even if they do work.

cameronsdad has pointed you in a good direction... stick with him :-)

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

1 script can manage the whole task easily and could run external scripts if desired.

If Not $cmdline[0] Then
;   ** Run Newsid (UID software) here **
    _RunOnce('/servername')
    Shutdown(6)
    Exit
ElseIf StringInStr($cmdlineraw, '/servername')
;   ** Change the server name here **
    _RunOnce('/adddomain')
    Shutdown(6)
    Exit
ElseIf StringInStr($cmdlineraw, '/adddomain')
;   ** Add server to the domain here **
    _RunOnce('/software')
    Shutdown(6)
    Exit
ElseIf StringInStr($cmdlineraw, '/software')
;   ** Automated software installation here **
    Exit
EndIf

Func _RunOnce($switch)
    Local $key = 'HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce'
    If @Compiled Then
        RegWrite($key, @ScriptName, 'Reg_sz', '"' & @ScriptFullPath & '" ' & $switch)
    Else
        RegWrite($key, @ScriptName, 'Reg_sz', '"' & @AutoItExe & '" "' & @ScriptFullPath & '" ' & $switch)
    EndIf
EndFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...