#166686 - 2006-08-31 04:39 PM
Kix to run Sequential code.. Guidance..
|
Gazzalad
Fresh Scripter
Registered: 2002-03-18
Posts: 22
Loc: Germany
|
I am coding a script that must run in a given order, ie instal a piece of software, stop a service then make some changes to the registry and then start the next install.
As a result I want to wait until one task has finished before starting the next task. Heres an example which I want to use to remove any old versions of ultravnc and replace with a new version:
Shell '%comspec% /c net stop "vnc server"' $ = DelTree ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\winvnc") $ = DelTree ("HKEY_LOCAL_MACHINE\SOFTWARE\ORL") $ = DelTree ("HKEY_LOCAL_MACHINE\SOFTWARE\ULTRAVNC") Run $path + 'UltraVNC\ultravnc.exe' Shell '%comspec% /c net stop "vnc server"' $ = DelTree ("HKEY_LOCAL_MACHINE\SOFTWARE\ORL") $ = DelTree ("HKEY_LOCAL_MACHINE\SOFTWARE\ULTRAVNC") $serverloc=$path+'UltraVNC\UVNC XP Clients Part 1.reg' $ClientLoc= $windir +'\tempy\' Copy $serverloc $ClientLoc $serverloc=$path+'UltraVNC\UVNC XP Clients Part 2.reg' Copy $serverloc $ClientLoc $serverloc=$path+'UltraVNC\video driver\' $ClientLoc= $windir +'\tempy\video driver' Copy $serverloc $ClientLoc $ClientLoc= "c:\program files\ultravnc\" $serverloc=$path+'UltraVNC\rc4.key' Copy $serverloc $ClientLoc $serverloc=$path+'UltraVNC\MSRC4Plugin.dsm' Copy $serverloc $ClientLoc Shell '%comspec% /c regedit /s "c:\tempy\UVNC XP Clients Part 1.reg"' Shell '%comspec% /c regedit /s "c:\tempy\UVNC XP Clients Part 2.reg"' Shell '%comspec% /c "c:\tempy\video driver\setupdrv install"' Shell '%comspec% /c net start "vnc server"' $ = WriteValue ($hklms, "UltraVNC", $NewVer, "REG_SZ")
But I have found that the code runs straight through, ie writes the final registry entry before the software is fully installed etc.
Is there a command I can use to wait until the previous task has finished before proceeding with the next line of code?
I have tried searching the forum but am not having any luck.
Many Thanks
G
|
Top
|
|
|
|
#166688 - 2006-08-31 04:56 PM
Re: Kix to run Sequential code.. Guidance..
|
Witto
MM club member
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
Found something here http://www.kixscripts.com/scriptlibrary/view.asp?id=166 and maybe STRCM can be of use to you. Installs on the fly when you need it. Also uninstalls after use (I think there are several antispyware programs who think of VNC as a threat)
|
Top
|
|
|
|
#166689 - 2006-08-31 04:56 PM
Re: Kix to run Sequential code.. Guidance..
|
Gazzalad
Fresh Scripter
Registered: 2002-03-18
Posts: 22
Loc: Germany
|
Sorry for appearing stupid here, but I am not exactly sure what you mean..
Do you mean to use the shell command in place of the run command or vice versa?
G
|
Top
|
|
|
|
#166691 - 2006-08-31 05:03 PM
Re: Kix to run Sequential code.. Guidance..
|
Witto
MM club member
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
I saw one RUN in your code Code:
Run $path + 'UltraVNC\ultravnc.exe'
Must this program start and should the script not wait before it terminates?
I would like to recommend STRCM.
|
Top
|
|
|
|
#166692 - 2006-08-31 05:15 PM
Re: Kix to run Sequential code.. Guidance..
|
Gazzalad
Fresh Scripter
Registered: 2002-03-18
Posts: 22
Loc: Germany
|
Appreciate the help guys and the STRCM tool.
However this is just one part of the code. There lots of other instrallations going on that I need to run sequentially..
Will try the shell option..
G
|
Top
|
|
|
|
#166694 - 2006-08-31 05:37 PM
Re: Kix to run Sequential code.. Guidance..
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Generally a command that you execute using "shell" will cause the script to pause until it the command has completed.
However, some programs release the console when they start or after they have unpacked the files and started the install part. This means that they appear to have completed, so the script continues.
There are a couple of ways to wait for the command to complete:
- Execute it using the DOS "start /wait" built-in. This sometimes works.
- Installer programs often have a "sms" flag or similar, which forces them to keep hold of the console.
- The most complex and least reliable option is to spawn the install process then read the running process table and wait for it to exit.
Hopefully one of these will work for you.
|
Top
|
|
|
|
#166695 - 2006-08-31 06:54 PM
Re: Kix to run Sequential code.. Guidance..
|
Gazzalad
Fresh Scripter
Registered: 2002-03-18
Posts: 22
Loc: Germany
|
The shell command is working perfectly for the applications I have to install. Many thanks guys..
Not wishing to push my luck but can anyone help me with this bit of code:
Shell '%comspec% /c regedit /s "c:\tempy\UVNC XP Clients Part 1.reg"'
I get an error saying UNC paths are not supported. Is there a way around this?
Cheers
G
|
Top
|
|
|
|
#166697 - 2006-08-31 07:37 PM
Re: Kix to run Sequential code.. Guidance..
|
Gazzalad
Fresh Scripter
Registered: 2002-03-18
Posts: 22
Loc: Germany
|
Fantastic.
Many thanks guys it looking like its working now!
G
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 466 anonymous users online.
|
|
|