BlueMe Posted January 20, 2006 Posted January 20, 2006 (edited) Hi ! I'm having some trouble with these things. First i wanna launch a program with a vbscript :On Error Resume NextDim oShellSet oShell = WScript.CreateObject("WScript.shell")oShell.Run ("ResChange.exe -Width=1024 -Height=768 -Depth=16 -Refresh=75") WScript.Sleep 3000oShell.Run ("%SystemDrive\Program Files\MyApp\MyApp.exe")...the first line works fine because "ResChanger" is in system32, but the second , how can i use variables ?I've tried it like this :Dim Act, AP, Fso, SP, RunSet Act = CreateObject("WScript.Shell")Set Fso = CreateObject("Scripting.FileSystemObject")SP = Act.ExpandEnvironmentStrings("%SystemDrive%\Program Files")Act.Run ("%SystemDrive\Program Files\MyApp\MyApp.exe")..and many other waysI'm a complete noob at this.. i've put it all together from some pieces of code i've gaathered from all the net, so far i got some long and good scripts but this, no,no it wont work for me.Basicaly ..i need to run a program using variablesSecond ..i know the above script is a easy one, but i need another one but for this could you please direct me to a site or whatever ..if u dont feel like writing code for nothing...so.. i want to check trough WMI if the sound card is instaled and if it is to run a program. Thats all. Thank you for taking the time to read this ! Edited January 20, 2006 by BlueMe
gunsmokingman Posted January 21, 2006 Posted January 21, 2006 Hi ! I'm having some trouble with these things. First i wanna launch a program with a vbscript :On Error Resume NextDim oShellSet oShell = WScript.CreateObject("WScript.shell")oShell.Run ("ResChange.exe -Width=1024 -Height=768 -Depth=16 -Refresh=75") WScript.Sleep 3000oShell.Run ("%SystemDrive\Program Files\MyApp\MyApp.exe")...the first line works fine because "ResChanger" is in system32, but the second , how can i use variables ?I've tried it like this :Dim Act, AP, Fso, SP, RunSet Act = CreateObject("WScript.Shell")Set Fso = CreateObject("Scripting.FileSystemObject")SP = Act.ExpandEnvironmentStrings("%SystemDrive%\Program Files")Act.Run ("%SystemDrive\Program Files\MyApp\MyApp.exe")..and many other waysI'm a complete noob at this.. i've put it all together from some pieces of code i've gaathered from all the net, so far i got some long and good scripts but this, no,no it wont work for me.Basicaly ..i need to run a program using variablesSecond ..i know the above script is a easy one, but i need another one but for this could you please direct me to a site or whatever ..if u dont feel like writing code for nothing...so.. i want to check trough WMI if the sound card is instaled and if it is to run a program. Thats all. Thank you for taking the time to read this !First you cannot dim Run as that is a function of ActSecond I used The varible %ProgramFiles%Third I add Chr(34) to the star and end this helps with spaces in the nameFourth you are missing %SystemDrive -> this % from you scriptBelow is the code with a check to see if it there Dim Act, Fso, Prof_Exe Set Act = CreateObject("WScript.Shell") Set Fso = CreateObject("Scripting.FileSystemObject") Prof_Exe = Act.ExpandEnvironmentStrings("%ProgramFiles%\MyApp\MyApp.exe") If Fso.FileExists(Prof_Exe) Then Act.Run (Chr(34) & Prof_Exe & Chr(34)) Else Act.Popup "It Missing" & vbcrlf & Prof_Exe, 15,"Error", 0 + 64 End If
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