Stuart_C Posted January 10, 2011 Posted January 10, 2011 (edited) 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: Dim FilePath Dim fso Dim FileNumber 'Sets the value of the variable FilePath FilePath = "C:\Program Files\\" 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 "\\\\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 \\\\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? Edited January 10, 2011 by Stuart_C
PiqueABoo Posted January 10, 2011 Posted January 10, 2011 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.
Stuart_C Posted January 10, 2011 Author Posted January 10, 2011 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.
ChrisH Posted January 10, 2011 Posted January 10, 2011 Make the command line into a string and then use that as the argument for the run command.
Stuart_C Posted January 11, 2011 Author Posted January 11, 2011 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
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