In a batch file you can test for a program running like this:
tasklist gives a list of running processes; that's then piped through find to look for a particular process and the result redirected to nul (so no text on screen)
tasklist | find /i "excel" > nul
if errorlevel 2 goto problem
if errorlevel 1 goto notfound
if errorlevel 0 goto running
echo find didn't work
echo Excel not found
If the string is found then errorlevel is set to 0; if the string is not found it's set to 1; if find fails for some reason then you get error 2
Still probably easier with VBScript - what I tend to do is something like ChrisH suggests:
- this allows you to see what's going to be run and you can adjust quotes till you get them right!
sCmd="""C:\Program Files\Citrix\ICA Client\pn.exe"" & "" /APP Desktop"""