+ Post New Thread
Results 1 to 5 of 5
Coding Thread, Running a program from within a VBS script with variables in Coding and Web Development; I am trying to get a script to run that looks at a file version number on the PC and ...
  1. #1

    Join Date
    Nov 2007
    Location
    Rotherham
    Posts
    1,678
    Thank Post
    122
    Thanked 126 Times in 102 Posts
    Rep Power
    45

    Running a program from within a VBS script with variables

    I am trying to get a script to run that looks at a file version number on the PC and sees if it's up to date. If it is then it does nothing if it isnt then it runs a program. The problem is that i can get it to run the exe file but I can't get it to run the exe file with the parameters needed.

    PS, My coding-fu is weak.

    So Far I've got:

    Code:
    Dim FilePath
    Dim fso
    Dim FileNumber
    
    'Sets the value of the variable FilePath
    FilePath = "C:\Program Files\<program>\<local.exe>"
    Set fso = CreateObject("scripting.filesystemobject")
    Set wshShell = WScript.CreateObject ("WSCript.shell")
    
    FileNumber = fso.GetFileVersion (filepath)
    if(FileNumber = "x.x.x") then
    	msgbox "File Verson Up to Date"
    else
    	wshshell.run "\\<server>\<share>\exe" 
    	msgbox "Install Run"
    end if
    (The message boxes are for testing purposes)
    This seems to work OK however I can't seem to get it work with the variables.
    From the start menu I can easilly run
    \\<server>\<share>\exe /Variable1 /variable2

    Help? And whislt I am at it is there a way to make the script stop only when the exe has finished running?
    Last edited by Stuart_C; 10th January 2011 at 03:43 PM.

  2. #2

    Join Date
    Jan 2006
    Location
    Surburbia
    Posts
    2,178
    Thank Post
    74
    Thanked 307 Times in 243 Posts
    Rep Power
    115
    I only do JS, but it's calls the same WSH functions so it's just a case of translating to VBS (possibly just a case of removing the semi-colon). This example call with command line switches works for me:

    wshshell.Run("something.exe /a /b /c:hello", 0, true);

    The 0 is a windows style and that true is a boolean and tells it to wait until the EXE has finished running.

  3. #3

    Join Date
    Nov 2007
    Location
    Rotherham
    Posts
    1,678
    Thank Post
    122
    Thanked 126 Times in 102 Posts
    Rep Power
    45
    Cheers I'll have a look tomorrow. I don't think I've helped myself by posting this in the wrong forum as I think I should have put this in the scripting forum.

  4. #4
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    5,009
    Thank Post
    120
    Thanked 282 Times in 260 Posts
    Rep Power
    108
    Make the command line into a string and then use that as the argument for the run command.

  5. #5

    Join Date
    Nov 2007
    Location
    Rotherham
    Posts
    1,678
    Thank Post
    122
    Thanked 126 Times in 102 Posts
    Rep Power
    45
    Thanks PiqueABoo that seems to work. I would swear blind I tried that but without he run comand switches. However when I added them it worked. Which is why I hate programming!

    Cheers again

SHARE:
+ Post New Thread

Similar Threads

  1. Stop users from running .vbs
    By marc2510 in forum Scripts
    Replies: 9
    Last Post: 2nd April 2010, 03:04 PM
  2. VBS Script
    By Lipjam in forum Windows
    Replies: 4
    Last Post: 2nd December 2009, 07:54 PM
  3. Sub within a sub - VBS Script
    By FN-GM in forum Scripts
    Replies: 5
    Last Post: 18th May 2008, 06:30 PM
  4. Kids Running VBS files
    By tomscaper in forum Scripts
    Replies: 8
    Last Post: 9th January 2008, 12:36 PM
  5. VBS Drive script is running from
    By Samson in forum Scripts
    Replies: 5
    Last Post: 10th May 2007, 03:29 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
  •