+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 22
Coding Thread, Pass a program variable in VB Script? in Coding and Web Development; I'd like to launch an exe in my VB script and then pass a config variable to it, this works ...
  1. #1
    cookie_monster's Avatar
    Join Date
    May 2007
    Location
    Derbyshire
    Posts
    4,196
    Thank Post
    392
    Thanked 278 Times in 239 Posts
    Rep Power
    74

    Pass a program variable in VB Script?

    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.

    Code:
    MyObj.Run "C:\Program Files\Citrix\ICA Client\pn.exe /APP "Desktop""
    Thanks.

  2. #2

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,705
    Thank Post
    3,239
    Thanked 1,045 Times in 967 Posts
    Rep Power
    363
    Quote Originally Posted by cookie_monster View Post
    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.

    Code:
    MyObj.Run "C:\Program Files\Citrix\ICA Client\pn.exe /APP "Desktop""
    Thanks.
    Code:
    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

  3. #3
    cookie_monster's Avatar
    Join Date
    May 2007
    Location
    Derbyshire
    Posts
    4,196
    Thank Post
    392
    Thanked 278 Times in 239 Posts
    Rep Power
    74
    Quote Originally Posted by mac_shinobi View Post
    Code:
    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
    Code:
    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.

  4. #4
    p858snake's Avatar
    Join Date
    Dec 2008
    Location
    Queensland
    Posts
    1,490
    Thank Post
    37
    Thanked 175 Times in 151 Posts
    Blog Entries
    2
    Rep Power
    51
    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)

  5. #5

    ZeroHour's Avatar
    Join Date
    Dec 2005
    Location
    Edinburgh, Scotland
    Posts
    5,641
    Thank Post
    894
    Thanked 1,314 Times in 798 Posts
    Blog Entries
    1
    Rep Power
    441
    You could try:
    MyObj.Run """C:\Program Files\Citrix\ICA Client\pn.exe"" & "" /APP Desktop"""
    "" means to literally print "

  6. #6
    cookie_monster's Avatar
    Join Date
    May 2007
    Location
    Derbyshire
    Posts
    4,196
    Thank Post
    392
    Thanked 278 Times in 239 Posts
    Rep Power
    74
    Quote Originally Posted by ZeroHour View Post
    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

  7. #7

    Join Date
    Feb 2006
    Location
    Derbyshire
    Posts
    1,381
    Thank Post
    181
    Thanked 211 Times in 171 Posts
    Rep Power
    65
    Do it the lazy way, write the .bat file out then launch that from the VBS instead

  8. #8
    cookie_monster's Avatar
    Join Date
    May 2007
    Location
    Derbyshire
    Posts
    4,196
    Thank Post
    392
    Thanked 278 Times in 239 Posts
    Rep Power
    74
    Quote Originally Posted by OutToLunch View Post
    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.

  9. #9

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,705
    Thank Post
    3,239
    Thanked 1,045 Times in 967 Posts
    Rep Power
    363
    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 ?

  10. #10
    p858snake's Avatar
    Join Date
    Dec 2008
    Location
    Queensland
    Posts
    1,490
    Thank Post
    37
    Thanked 175 Times in 151 Posts
    Blog Entries
    2
    Rep Power
    51
    Quote Originally Posted by cookie_monster View Post
    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.

  11. #11
    cookie_monster's Avatar
    Join Date
    May 2007
    Location
    Derbyshire
    Posts
    4,196
    Thank Post
    392
    Thanked 278 Times in 239 Posts
    Rep Power
    74
    Quote Originally Posted by p858snake View Post
    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.

  12. #12
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,999
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106
    Quote Originally Posted by cookie_monster View Post
    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.
    Last edited by ChrisH; 8th January 2010 at 02:23 PM.

  13. Thanks to ChrisH from:

    cookie_monster (8th January 2010)

  14. #13
    cookie_monster's Avatar
    Join Date
    May 2007
    Location
    Derbyshire
    Posts
    4,196
    Thank Post
    392
    Thanked 278 Times in 239 Posts
    Rep Power
    74
    Quote Originally Posted by ChrisH View Post
    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.

  15. #14
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,999
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106
    See my edit and see if that works first.

  16. #15

    ZeroHour's Avatar
    Join Date
    Dec 2005
    Location
    Edinburgh, Scotland
    Posts
    5,641
    Thank Post
    894
    Thanked 1,314 Times in 798 Posts
    Blog Entries
    1
    Rep Power
    441
    Try:
    Code:
    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.

  17. Thanks to ZeroHour from:

    cookie_monster (8th January 2010)

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Program or Script to add URLS to a URL sets in ISA server.
    By FN-GM in forum Internet Related/Filtering/Firewall
    Replies: 9
    Last Post: 3rd July 2009, 06:44 PM
  2. Copy file across variable folder name
    By SimpleSi in forum *nix
    Replies: 11
    Last Post: 10th March 2009, 06:15 PM
  3. Moodle - undefined variable error
    By damienharrison in forum Virtual Learning Platforms
    Replies: 5
    Last Post: 26th September 2007, 10:15 AM
  4. Batch: Text file -> Environment variable?
    By PiqueABoo in forum Scripts
    Replies: 5
    Last Post: 13th December 2006, 11:09 PM
  5. %Userprofile% Variable not being set.
    By drjturner in forum Windows
    Replies: 16
    Last Post: 23rd November 2006, 09:07 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •