OK here goes...
My compnay uses a docmuent management app called Solidworks PDM Enterprise. This app has a feature called dispatch that will launch any app or script that I throw at it and will do so only when a file in the vault has changed to a particular state such as when it enters "work in progress".
My task is to have the dispatch launch a command\script that will do the following:
Note: %Filepath%, %PathtoPDFS% and %filename% are variables that I created in PDM.
The most important one is %filename%.
*This triggers the first part of the action script
when %filename%.prt enters "work in progress" then
*This will close the connection to the file on the server
cmd /c \\Servername\c$\pstools\Psfile.exe \\Servername "%PathtoPDFs%%filename%.pdf" -c
*This will delete the file
*This will launch a batch file on the remote clients pc
\\Servername\c$\pstools\psexec @hosts.txt -i -s cmd.exe /c c:\taskkill.bat %filename%
*This is the batch file. It closes whatever application the client was using to view the file
Taskkill.exe /FI "WINDOWTITLE eq %1.*"
My problem is that Taskkill.exe /FI "WINDOWTITLE eq %1.*" will only work if the app that has the file open is the active window. So if the user has file %filename%.pdf open and they have Adobe Reader minimized then taskkill connot read the windowtitle. I was thinking that a vbscript could help and found a few things on the web refering to setactivewindow and setforegroundwindow. I think this may work but im not sure how to go about writing it. Im somewhat familiar with vb script but I've never written anything quite like this. In short I need help!
P.S. I need to be able to launch the script like this:
"c:\windows\system32\wscript\script.vbs %filename%" where %filename% is NOT a static filename. Disptach will pass the filename to the script.