mIRC Home    About    Download    Register    News    Help

Print Thread
Halting process of a script until cmd.exe finished #214398 02/08/09 09:28 AM
Joined: Oct 2005
Posts: 122
O
onesikgypo Offline OP
Vogon poet
OP Offline
Vogon poet
O
Joined: Oct 2005
Posts: 122
Hey,

I'm quite sure there is no efficient way to do this, however i thought id ask incase there was some trick that could be used, other then using a generic timer to execute a secondary script.

I have a script which at one point runs the command prompt to do something

Code:
 run RandomProgram.exe >randomtext.txt 


As im aware theres only two different methods (neither which i like particularly) to ensure that randomtext.txt doesnt get processed until the command has been completed.

The first is to use a timer, and have the rest of the script in there, the next is to have an ok $input - and ask them to click ok once its done.

I was wondering if there was perhaps some other clever way of doing it.

Re: Halting process of a script until cmd.exe finished [Re: onesikgypo] #214399 02/08/09 12:34 PM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Code:
alias wrun {
  var %obj = wrun $+ $ticks
  .comopen %obj wscript.shell
  .comclose %obj $com(%obj,run,3,bstr,$1-)
}


wrun RandomProgram.exe >randomtext.txt

Re: Halting process of a script until cmd.exe finished [Re: hixxy] #214631 10/08/09 02:39 PM
Joined: Oct 2005
Posts: 122
O
onesikgypo Offline OP
Vogon poet
OP Offline
Vogon poet
O
Joined: Oct 2005
Posts: 122
Hi,

Sorry for the delay ive been quite busy and this totally got out of my mind.

I tried using the code you gave, however it didnt work, so perhaps ive misunderstood how to use it, or i didnt explain exactly what i meant.

Take for example the following script:

Code:
alias examplescript {
run RandomProgram.exe >randomtext.txt
msg $chan Back Up Complete!
}


Now the purpose of this script is to msg the channel once the command has been fully exectued. The actual program may take 5mins to finish. However, mirc script doesnt pause, so as soon as the program is executed, at the same instant, the msg is sent. What i was looking for was for randomprogram.exe to finish executing, then for the msg to be sent.

Now using your code, i tried just replacing run with wrun:


Code:
alias examplescript {
wrun RandomProgram.exe >randomtext.txt
msg $chan Back Up Complete!
}


However, the same result occured, with the next line of coding being processed right away.



Re: Halting process of a script until cmd.exe finished [Re: onesikgypo] #214633 10/08/09 03:51 PM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
You'll likely need a DLL to do this effectively. Try: http://kthx.net/clb/exec


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"