salezica
salezica

Reputation: 77029

Windows: wait for process to finish

I have to make a short Windows shell script. Please don't run away. It couldn't be simpler, but I just can't find the way to make this frankly primitive command-line to work with me.

I simply want to run dxdiag, and do something with the gathered data.

Thing is, I can't get the script to wait for dxdiag to finish, since it spawns the process and keeps on going. I need the file to exist and have the information before moving on to the next line.

Using start /wait has no effect, I'm guessing because there's no GUI involved.

I'm starting to think this isn't possible. Please help!

Upvotes: 1

Views: 1379

Answers (2)

James
James

Reputation: 25

Do something similar to THIS code:

tasklist /FI "IMAGENAME eq dxdiag.exe" 2>NUL | find /I /N "dxdiag.exe">NUL
if "%ERRORLEVEL%"=="0" goto next_area_here
  • if errorlevel is returned as 0, dxdiag in this case is CLOSED
  • if errorlevel returned as 1, dxdiag in this case is OPEN

Upvotes: 1

Anuraj
Anuraj

Reputation: 19598

I tried something like this

start /wait dxdiag /x:SomeXmlFile

And it is working for me in Windows Vista.

Upvotes: 1

Related Questions