cookie_monster Posted January 8, 2010 Posted January 8, 2010 I'd like to launch an exe in my VB script and then pass a config variable to it, this works fine in a bat file but not in my VBScript. Can anyone point me in the right direction? The Desktop text at the end tells the citrix client what desktop to launch this is the bit that fails. MyObj.Run "C:\Program Files\Citrix\ICA Client\pn.exe /APP "Desktop"" Thanks.
mac_shinobi Posted January 8, 2010 Posted January 8, 2010 I'd like to launch an exe in my VB script and then pass a config variable to it, this works fine in a bat file but not in my VBScript. Can anyone point me in the right direction? The Desktop text at the end tells the citrix client what desktop to launch this is the bit that fails. MyObj.Run "C:\Program Files\Citrix\ICA Client\pn.exe /APP "Desktop""Thanks. MyObj.Run "C:\Program Files\Citrix\ICA Client\pn.exe /APP Desktop" If you do the above does that help at all ? If not then if you change the .Run to .Exec And try again
cookie_monster Posted January 8, 2010 Author Posted January 8, 2010 MyObj.Run "C:\Program Files\Citrix\ICA Client\pn.exe /APP Desktop" If you do the above does that help at all ? If not then if you change the .Run to .Exec And try again I changed the path to MyObj.Run "C:\Citrix\ICAClient\pn.exe" without the gaps in the path the PNAgent now runs but I still can't get it to accept the desktop command, changing Run to Exec didn't seem to help either. Thanks.
p858snake Posted January 8, 2010 Posted January 8, 2010 If i remember correctly, this guide mentions that on one of the pages Launching and Monitoring External Programs from VB.NET Applications (book marked and i'm too lazy to open it)
ZeroHour Posted January 8, 2010 Posted January 8, 2010 You could try: MyObj.Run """C:\Program Files\Citrix\ICA Client\pn.exe"" & "" /APP Desktop""" "" means to literally print "
cookie_monster Posted January 8, 2010 Author Posted January 8, 2010 You could try: MyObj.Run """C:\Program Files\Citrix\ICA Client\pn.exe"" & "" /APP Desktop""" "" means to literally print " That launches the pnagent but doesn't connect to the desktop
OutToLunch Posted January 8, 2010 Posted January 8, 2010 Do it the lazy way, write the .bat file out then launch that from the VBS instead
cookie_monster Posted January 8, 2010 Author Posted January 8, 2010 Do it the lazy way, write the .bat file out then launch that from the VBS instead That brings about another problem of the bat file pausing if the exe is already running.
mac_shinobi Posted January 8, 2010 Posted January 8, 2010 Bit of a daft question but if this was a windows shortcut would it be X:\folder\app.exe -switch or what would it look like ?
p858snake Posted January 8, 2010 Posted January 8, 2010 That brings about another problem of the bat file pausing if the exe is already running. have a "if" statement that checks to see if it is running and if it is then kill it or if not it starts it.
cookie_monster Posted January 8, 2010 Author Posted January 8, 2010 have a "if" statement that checks to see if it is running and if it is then kill it or if not it starts it. That would be lovely but I can't think of a way to query a running process in a batch file. Do you know how I'd love to hear about it I really need it to just skip the line if the exe is running rather than kill it.
ChrisH Posted January 8, 2010 Posted January 8, 2010 (edited) That would be lovely but I can't think of a way to query a running process in a batch file. Do you know how I'd love to hear about it I really need it to just skip the line if the exe is running rather than kill it. Process the results if the "tasklist" command or just use "taskkill" and make sure it can handle an error. Also in your original script build the command line up into a variable and pass that as the argument rather than the text string. I find this makes a difference sometimes. Edited January 8, 2010 by ChrisH 1
cookie_monster Posted January 8, 2010 Author Posted January 8, 2010 Process the results if the "tasklist" command or just use "taskkill" and make sure it can handle an error. I'm not sure how to do that in a batch script any examples out there that you can post? I don't want to kill the task though I just want the script to skip the line rather than execute if the task already exists. Thanks.
ZeroHour Posted January 8, 2010 Posted January 8, 2010 Try: MyObj.Run "'C:\Program Files\Citrix\ICA Client\pn.exe' /APP Desktop" BTW I know for a fact .run can pass switches because I have script running "msiexec.exe /i {path to blah}" and it works fine. The problem you have is isolating the spaces for the path name. Also ~1 could be used dos style to try and get around it. 1
cookie_monster Posted January 8, 2010 Author Posted January 8, 2010 See my edit and see if that works first. I don't see an edit what am I missing? I'm actually just taking a look at the link below to see if it's possible with a bat file. How to check if a process is running via a batch script - Stack Overflow
srochford Posted January 8, 2010 Posted January 8, 2010 (edited) In a batch file you can test for a program running like this: @echo off tasklist | find /i "excel" > nul if errorlevel 2 goto problem if errorlevel 1 goto notfound if errorlevel 0 goto running :problem echo find didn't work goto end :notfound echo Excel not found goto end :running echo running :end 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) 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: sCmd="""C:\Program Files\Citrix\ICA Client\pn.exe"" & "" /APP Desktop""" wscript.echo sCmd oShell.run scmd - this allows you to see what's going to be run and you can adjust quotes till you get them right! Edited January 8, 2010 by ChrisH
cookie_monster Posted January 8, 2010 Author Posted January 8, 2010 In a batch file you can test for a program running like this: @echo off tasklist | find /i "excel" > nul if errorlevel 2 goto problem if errorlevel 1 goto notfound if errorlevel 0 goto running :problem echo find didn't work goto end :notfound echo Excel not found goto end :running echo running :end 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) 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: sCmd="""C:\Program Files\Citrix\ICA Client\pn.exe"" & "" /APP Desktop""" wscript.echo sCmd oShell.run scmd - this allows you to see what's going to be run and you can adjust quotes till you get them right! I'd like it to run in a VB script so i'll take a look later for now I have a working batch file, I did have to borrow tasklist.exe from an XP Pro box as it's not on XP Home grrrrrr tasklist /FI "IMAGENAME eq tray.exe" /FO CSV > search.log FOR /F %%A IN (search.log) DO IF %%~zA EQU 0 GOTO end "C:\Program Files\Citrix\ICA Client\pn.exe" /APP "Desktop" start "" "C:\Program Files\Hotkey Utility\tray.exe" :end del search.log
cookie_monster Posted January 8, 2010 Author Posted January 8, 2010 Try: MyObj.Run "'C:\Program Files\Citrix\ICA Client\pn.exe' /APP Desktop" BTW I know for a fact .run can pass switches because I have script running "msiexec.exe /i {path to blah}" and it works fine. The problem you have is isolating the spaces for the path name. Also ~1 could be used dos style to try and get around it. I did move the pn.exe app to C:\ICAClient and it still wouldn't work, I did check that it would work manually from there as well
mac_shinobi Posted January 8, 2010 Posted January 8, 2010 (edited) see below as found a website that think might have the code you are after http://www.brianmadden.com/forums/t/35813.aspx Dim WshShell set WshShell = CreateObject("WScript.Shell") Wshshell.Run """c:\Program Files\Citrix\ICA Client\pn.exe"" /APP ""Desktop""", 1, True sorry I couldn't help that much earlier - got a cruddy net connection at work and got a bit snowed under work wise Edited January 8, 2010 by mac_shinobi 1
cookie_monster Posted January 8, 2010 Author Posted January 8, 2010 see below as found a website that think might have the code you are after VBScript to Launch Desktop Automatically, in the Scripting / Automation forum on BrianMadden.com Dim WshShell set WshShell = CreateObject("WScript.Shell") Wshshell.Run """c:\Program Files\Citrix\ICA Client\pn.exe"" /APP ""Desktop""", 1, True sorry I couldn't help that much earlier - got a cruddy net connection at work and got a bit snowed under work wise Thanks I'll give it a try on monday, I feel better now knowing the batch file works as well. The ThinXP software is going to be great on our wireless netbooks
asifm Posted April 22, 2013 Posted April 22, 2013 I'd like to launch an exe in my VB script and then pass a config variable to it, this works fine in a bat file but not in my VBScript. Can anyone point me in the right direction? The Desktop text at the end tells the citrix client what desktop to launch this is the bit that fails. MyObj.Run "C:\Program Files\Citrix\ICA Client\pn.exe /APP "Desktop"" Thanks. Hello, Can i get that batch which the exe please?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now