Page 1 of 1 1
Topic Options
#166686 - 2006-08-31 04:39 PM Kix to run Sequential code.. Guidance..
Gazzalad Offline
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
#166687 - 2006-08-31 04:46 PM Re: Kix to run Sequential code.. Guidance..
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Change "Run" in "Shell"
[Edit]
Or would that be to easy at second view...
[/Edit]


Edited by Witto (2006-08-31 04:49 PM)

Top
#166688 - 2006-08-31 04:56 PM Re: Kix to run Sequential code.. Guidance..
Witto Offline
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 Offline
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
#166690 - 2006-08-31 04:59 PM Re: Kix to run Sequential code.. Guidance..
eriqjaffe Offline
Hey THIS is FUN

Registered: 2004-06-24
Posts: 214
Loc: Arlington Heights, IL USA
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).

Edited by eriqjaffe (2006-08-31 05:00 PM)

Top
#166691 - 2006-08-31 05:03 PM Re: Kix to run Sequential code.. Guidance..
Witto Offline
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 Offline
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
#166693 - 2006-08-31 05:21 PM Re: Kix to run Sequential code.. Guidance..
private_meta Offline
Getting the hang of it

Registered: 2006-07-27
Posts: 80
Loc: Austria
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
Top
#166694 - 2006-08-31 05:37 PM Re: Kix to run Sequential code.. Guidance..
Richard H. Administrator Offline
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:
  1. Execute it using the DOS "start /wait" built-in. This sometimes works.
  2. Installer programs often have a "sms" flag or similar, which forces them to keep hold of the console.
  3. 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 Offline
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
#166696 - 2006-08-31 07:24 PM Re: Kix to run Sequential code.. Guidance..
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yep.
use this:
Shell 'regedit /s "c:\tempy\UVNC XP Clients Part 1.reg"'

Top
#166697 - 2006-08-31 07:37 PM Re: Kix to run Sequential code.. Guidance..
Gazzalad Offline
Fresh Scripter

Registered: 2002-03-18
Posts: 22
Loc: Germany
Fantastic.

Many thanks guys it looking like its working now!

G

Top
#166698 - 2006-08-31 09:30 PM Re: Kix to run Sequential code.. Guidance..
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
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?
Top
#166699 - 2006-08-31 09:48 PM Re: Kix to run Sequential code.. Guidance..
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I think not.
as comspec errors, it doesn't execute the command.

Top
#166700 - 2006-08-31 11:09 PM Re: Kix to run Sequential code.. Guidance..
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
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.

Top
#166701 - 2006-08-31 11:20 PM Re: Kix to run Sequential code.. Guidance..
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
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.
Top
#166702 - 2006-08-31 11:54 PM Re: Kix to run Sequential code.. Guidance..
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Well it depends on what commands were in the batch.

But yes, I think that is where the error is coming from.

Top
#166703 - 2006-09-01 12:20 AM Re: Kix to run Sequential code.. Guidance..
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
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.
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 466 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.069 seconds in which 0.023 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org