Batch User Posted December 31, 2006 Share Posted December 31, 2006 How do i use Set oWsh = CreateObject("WScript.Shell") to run a .exe, because I know for some reason the path is different... or something.oWsh.Run "C:\path" Doesnt work..Thanks. Link to comment Share on other sites More sharing options...
gunsmokingman Posted December 31, 2006 Share Posted December 31, 2006 (edited) Run Something And Wait For It To FinishDim Act : Set Act = CreateObject("Wscript.Shell") Act.Run("Notepad.exe"),1,TrueRun Something And Not Wait For It To FinishDim Act : Set Act = CreateObject("Wscript.Shell") Act.Run("Notepad.exe"),1,FalseRun Somthing With A Space In It Path Dim Act : Set Act = CreateObject("Wscript.Shell") Dim File : File = Act.ExpandEnvironmentStrings("%ProgramFiles%\Winamp\winamp.exe") Act.Run(Chr(34) & File & Chr(34)),1,TrueCheck For File Then Run It And Wait For it To Complete Dim Act : Set Act = CreateObject("Wscript.Shell") Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject") Dim File : File = Act.ExpandEnvironmentStrings("%ProgramFiles%\Winamp\winamp.exe") If Fso.FileExists(File) Then Act.Run(Chr(34) & File & Chr(34)),1,True Else Act.Popup "Can Not Find Winamp",5,"Missing", 4128 End IfCheck For File Then Run It And Not Wait For it To Complete Dim Act : Set Act = CreateObject("Wscript.Shell") Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject") Dim File : File = Act.ExpandEnvironmentStrings("%ProgramFiles%\Winamp\winamp.exe") If Fso.FileExists(File) Then Act.Run(Chr(34) & File & Chr(34)),1,False Else Act.Popup "Can Not Find Winamp",5,"Missing", 4128 End If Edited December 31, 2006 by gunsmokingman Link to comment Share on other sites More sharing options...
Fredledingue Posted January 11, 2007 Share Posted January 11, 2007 It works, but it doesn't accept "white spaces" in the path (thought it accept long names if no white space!).So use:Set Fso = CreateObject("Scripting.FileSystemObject")Set f = Fso.GetFile(MyPath)oWsh.Run f.ShortPathThat way you are sure there will be no white space in the pathYou can lauch files or exe alike. Link to comment Share on other sites More sharing options...
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