Jump to content

Recommended Posts

Posted

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.

Posted
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

Posted
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.

Posted
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.

Posted
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 :D

 

I really need it to just skip the line if the exe is running rather than kill it.

Posted (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 :D

 

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 by ChrisH
  • Thanks 1
Posted
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.

Posted

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.

  • Thanks 1
Posted (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 by ChrisH
Posted
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

Posted
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 ;)

Posted (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 by mac_shinobi
  • Thanks 1
Posted
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 :D

  • 3 years later...
Posted
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?

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...