Resolved question

Wait for an elevated process

by redespace - 5/12/11 4:04 PM

Hi guys. Until know I've been using the following script for shutting down the PC after my VLC player - playlist finishes:

START /WAIT D:\"Program Files"\VideoLan\VLC\vlc.exe %1 vlc://quit
shutdown -s -t 60

Those 2 lines were enough to create a bat file, and every time before going to bed, I just drag a video file into it and after finishing the PC shuts down.

Now, I realized that sometimes, I had some Windows updates waiting to be installed after shutdown, but the problem was that shutdown.exe will not install the downloaded updates. They will only install if you go to the start menu and click "Install updates and shutdown". For fixing this I started using "wuinstall". a little tool that lets you check for updates and install them via command-line. Then my bat file became like:

START /WAIT D:\"Program Files"\VideoLan\VLC\vlc.exe %1
START /WAIT C:\Users\Rafael\Downloads\WuInstall1_1\WUInstall.exe /install
vlc://quitshutdown -s -t 60

The problem with the above code, is that WuInstall needs elevation for letting it download and install updates. Then I tried:

START /WAIT D:\"Program Files"\VideoLan\VLC\vlc.exe %1
runas /user:Rafael-PC\Rafael /savecred C:\Users\Rafael\Downloads\WuInstall1_1\WUInstall.exe /installvlc://quitshutdown -s -t 60

The problems with that, is that RUNAS won't let you wait until WuInstall finishes. I don't want the PC shutting down while a major Windows update is going. I also tried it with the elevate64 tool but the problem is that elevate64 does not let you specify the user and password, thus it will always popup the UAC account control message. I tried creating a shortcut to the bat file and right click -- properties -- shortcut -- advanced -- run as admin .. But the shortcut wont pass the parameters (the VLC playlist) to the bat file. Can some one please help me solve this problem? is there a work around?

Thank you