+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
Coding Thread, Pass a program variable in VB Script? in Coding and Web Development; Originally Posted by ChrisH See my edit and see if that works first. I don't see an edit what am ...
  1. #16
    cookie_monster's Avatar
    Join Date
    May 2007
    Location
    Derbyshire
    Posts
    4,217
    Thank Post
    394
    Thanked 278 Times in 239 Posts
    Rep Power
    75
    Quote Originally Posted by ChrisH View Post
    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

  2. #17

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,159
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    125
    In a batch file you can test for a program running like this:
    Code:
    @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:

    Code:
    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!
    Last edited by ChrisH; 8th January 2010 at 03:50 PM.

  3. #18
    cookie_monster's Avatar
    Join Date
    May 2007
    Location
    Derbyshire
    Posts
    4,217
    Thank Post
    394
    Thanked 278 Times in 239 Posts
    Rep Power
    75
    Quote Originally Posted by srochford View Post
    In a batch file you can test for a program running like this:
    Code:
    @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:

    Code:
    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


    Code:
    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

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

    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

  5. #20

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    10,053
    Thank Post
    3,583
    Thanked 1,123 Times in 1,025 Posts
    Rep Power
    377
    see below as found a website that think might have the code you are after

    http://www.brianmadden.com/forums/t/35813.aspx

    Code:
    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
    Last edited by mac_shinobi; 8th January 2010 at 07:05 PM.

  6. Thanks to mac_shinobi from:

    cookie_monster (8th January 2010)

  7. #21
    cookie_monster's Avatar
    Join Date
    May 2007
    Location
    Derbyshire
    Posts
    4,217
    Thank Post
    394
    Thanked 278 Times in 239 Posts
    Rep Power
    75
    Quote Originally Posted by mac_shinobi View Post
    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

    Code:
    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

  8. #22

    Join Date
    Apr 2013
    Posts
    32
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    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.
    Hello,

    Can i get that batch which the exe please?



SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

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, 07:44 PM
  2. Copy file across variable folder name
    By SimpleSi in forum *nix
    Replies: 11
    Last Post: 10th March 2009, 07:15 PM
  3. Moodle - undefined variable error
    By damienharrison in forum Virtual Learning Platforms
    Replies: 5
    Last Post: 26th September 2007, 11:15 AM
  4. Batch: Text file -> Environment variable?
    By PiqueABoo in forum Scripts
    Replies: 5
    Last Post: 14th December 2006, 12:09 AM
  5. %Userprofile% Variable not being set.
    By drjturner in forum Windows
    Replies: 16
    Last Post: 23rd November 2006, 10: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
  •