RUNAS with wait for process exit.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
k4p
Posts: 4
Joined: 21 Jul 2010 01:17

RUNAS with wait for process exit.

#1 Post by k4p » 21 Jul 2010 01:24

Need to start process ("runas") with waiting for results (like "CALL" or "start /wait").. But, how do that? Thx..

Now use this construction:

1:
FOR "skip=3 tokens=1" %%i IN ('tasklist') DO IF %%i equ %wayted_process% GOTO 1


%-) have a simplest solve?

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: RUNAS with wait for process exit.

#2 Post by aGerman » 21 Jul 2010 08:25

I never used it, but did you try

Code: Select all

runas /user:XXXXX start "" /wait "xyz.exe"


Regards
aGerman

k4p
Posts: 4
Joined: 21 Jul 2010 01:17

Re: RUNAS with wait for process exit.

#3 Post by k4p » 21 Jul 2010 09:50

runas /user:test "start /wait calc.exe"

File not found: "start /wait calc.exe" :-)

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: RUNAS with wait for process exit.

#4 Post by aGerman » 21 Jul 2010 10:01

Of course. Have a look at the difference

Yours:
runas /user:test "start /wait calc.exe"

Mine:
runas /user:test start "" /wait "calc.exe"

Regards
aGerman

k4p
Posts: 4
Joined: 21 Jul 2010 01:17

Re: RUNAS with wait for process exit.

#5 Post by k4p » 21 Jul 2010 10:16

I tried that. Ofcourse RUNAS was return syntax error.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: RUNAS with wait for process exit.

#6 Post by aGerman » 21 Jul 2010 10:29

Hmm, try to escape the quots.
runas /user:test "start \"\" /wait \"calc.exe\""

Otherwise write the entire path.

Regards
aGerman

k4p
Posts: 4
Joined: 21 Jul 2010 01:17

Re: RUNAS with wait for process exit.

#7 Post by k4p » 21 Jul 2010 10:38

aGerman, no.. equivalently :)

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: RUNAS with wait for process exit.

#8 Post by aGerman » 21 Jul 2010 11:55

Strange. Let's wait for the "runas-experts".

Regards
aGerman

Post Reply