CCpluses


Hi

I am new in programming, I'd like to ask a basic question.

How to run *.vbs or *.bat in Excel VBS

I tried the code but it didn't work

Sub Test()

Set ws = WScript.CreateObject("WScript.Shell")
ws.Run ("Notepad")

End Sub

thanks~




Re: How to run *.vbs or *.bat in Excel VBS?

MyLady


Hey,

Here you goĦ­

Sub Test()
Set ws = CreateObject("WScript.Shell")
ws.Run ("Notepad")
End Sub

Best Regards

Cathrine






Re: How to run *.vbs or *.bat in Excel VBS?

CCpluses

Hi Cathrine

It works, thank you very much.

My further question is

How to set batch file background work

Sub Test()
Set ws = CreateObject("WScript.Shell")
ws.Run ("batch.bat")
End Sub

BR,

CCplus





Re: How to run *.vbs or *.bat in Excel VBS?

MyLady

Hey,

You must use the full path to the file...

Sub Test()
Set ws = CreateObject("WScript.Shell")
ws.Run ("C:\batch.bat")
End Sub

Cath