Running a .cmd or bat file

How do I run a .cmd file?
f = getfolderitem (“c:\myfile.cmd”)
write to it using a text output stream (no problem)
close the stream

f.Launch doesn’t do anything but if I double click the file it runs the batch

thx

On the Mac I’d execute this in a shell. Have you tried this in a Windows shell?

[quote=232727:@Jym Morton]How do I run a .cmd file?
f = getfolderitem (“c:\myfile.cmd”)
write to it using a text output stream (no problem)
close the stream

f.Launch doesn’t do anything but if I double click the file it runs the batch

thx[/quote]

Rename it to .bat.

You should be able to execute it in an interactive Shell too.

I renamed it bat as suggested (old school) launch still didn’t work
I’m not sure what I’m supposed to put into the shell to get it to work
Dim sh as New Shell
Now what?

sh.Execute(“run c:\myfile.bat”)
sh.Execute(“cmd c:\myfile.cmd”)

neither are doing anything.

I did this in the Kaju project but am not by machine to look right now.

Https://github.com/ktekinay/Kaju

Wait, if you don’t need the console to open, can’t you just call it with its full path?

If I do
sh.Execute(“c:\wget\text.bat”) the error I get is wget is not a command or batch

sh.Execute("cmd /c c:\\wget\\text.bat")

or

sh.Execute("c:\\windows\\system32\\cmd.exe /c c:\\wget\\text.bat")

Brilliant thank you!!

you may also use start command…