Jump to content

Recommended Posts

Posted (edited)

Hi ! I'm having some trouble with these things. First i wanna launch a program with a vbscript :

On Error Resume Next
Dim oShell
Set oShell = WScript.CreateObject("WScript.shell")
oShell.Run ("ResChange.exe -Width=1024 -Height=768 -Depth=16 -Refresh=75")
WScript.Sleep 3000
oShell.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, Run
Set 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 ways

I'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 variables

Second ..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 by BlueMe

Posted
Hi ! I'm having some trouble with these things. First i wanna launch a program with a vbscript :

On Error Resume Next
Dim oShell
Set oShell = WScript.CreateObject("WScript.shell")
oShell.Run ("ResChange.exe -Width=1024 -Height=768 -Depth=16 -Refresh=75")
WScript.Sleep 3000
oShell.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, Run
Set 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 ways

I'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 variables

Second ..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 Act

Second I used The varible %ProgramFiles%

Third I add Chr(34) to the star and end this helps with spaces in the name

Fourth you are missing %SystemDrive -> this % from you script

Below 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...