Quantcast
Channel: Active questions tagged windows - Super User
Viewing all articles
Browse latest Browse all 9656

How can I make runas.exe (Windows) wait until the program it starts exits?

$
0
0

That is, I want runas to exit only after the program that it runs exits.

There is no /wait argument to runas.exe. I've tried lots of permutations of start /wait with it and nothing works.

I have to use runas because I need elevated privileges for the program, so I need to start it like this:

runas /user:administrator /savedcred /env update.exe

where update.exe is my program. runas is being called from a Cygwin Bash, as well, to make it even more complicated.

I'm on Server 2008 R2.

Well, this is one way to solve it. It uses the Sysinternalspslist program and Bash:

do_update(){if test -d c:/; then    case `hostname` in    thor*)        update="runas /user:administrator /savedcred /env \".\\update.exe\""        ;;        *)  update="./update.exe" ;;    esac    $update    while pslist -e update > /dev/null 2>&1; do        echo waiting for update.exe to finish...    sleep 3    doneelse    ./update.shfi}

It is horribly hacky, though, mainly because it cannot get the exit status of the program back to the caller. That is a huge problem, IMO.


Viewing all articles
Browse latest Browse all 9656

Trending Articles