|
|
|||||||
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 |
||||||||
|
|
|||||||
Change "Run" in "Shell" [Edit] Or would that be to easy at second view... [/Edit] |
||||||||
|
|
|||||||
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) |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
Yes. RUN will spawn an external process and continue the script, SHELL will spawn the process and wait for it to end before continuing. Personally, I almost never use RUN statements, since I'm usually only running external commands because they're needed to do things that KiXtart can't do by itself (or, at least, not without jumping through too many hoops). |
||||||||
|
|
|||||||
I saw one RUN in your code Code:
Must this program start and should the script not wait before it terminates? I would like to recommend STRCM. |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
If you have the Setup Zipped into an Exe-File it can happen that the SHELL-Command sees the Application done once the unzipper is done unpacking. Maybe you could use some shell-bashed unzipper, in case you need to install more stuff... you might not need this info, but just in case it could be helpful |
||||||||
|
|
|||||||
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:
Hopefully one of these will work for you. |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
yep. use this: Shell 'regedit /s "c:\tempy\UVNC XP Clients Part 1.reg"' |
||||||||
|
|
|||||||
Fantastic. Many thanks guys it looking like its working now! G |
||||||||
|
|
|||||||
Jooel, I would think that %comspec% is giving the message that UNC paths are not supported, but the regedit thing should work afterwards, shouldn't it? |
||||||||
|
|
|||||||
I think not. as comspec errors, it doesn't execute the command. |
||||||||
|
|
|||||||
That is not his error I don't think. It is probably there from other code in his script, or he is calling the script from a batch file. BATCH files do not properly support UNC paths. This works: Shell '%comspec% /c regedit /s "c:\tempy\UVNC XP Clients Part 1.reg"' and this works: Shell 'regedit /s "c:\tempy\UVNC XP Clients Part 1.reg"' But why call %comspec% if you don't need to. He needs to look elsewhere in his code for the UNC error message as it is not being created by this process. |
||||||||
|
|
|||||||
I knew I had seen the message somewhere. It was with BATCH files and UNC paths. Thanks Doc for refreshing my memory. I have used for a while batch files that I called from a path like "\\server\share$\InstallPackxxx\install.cmd" I got that "error" message but it was never a problem to the rest of the commands. |
||||||||
|
|
|||||||
Well it depends on what commands were in the batch. But yes, I think that is where the error is coming from. |
||||||||
|
|
|||||||
AFAIK that error is just cosmetic and does not stop processing. I agree with DOC. In and of itself, SHELLing to comspec should not spawn that error, only if a BATch script is involved. |