07-23-2023, 10:33 AM
I'm trying to run a bat file using javascript. I've tried using powershell but it didn't seem to work properly. Here is the code I tried:
var oShell = WScript.CreateObject("WScript.Shell");
oShell.Exec("D:");
oShell.Exec("cd dir");
oShell.Exec("start user.bat");
I've also tried that:
var oShell = WScript.CreateObject("WScript.Shell");
oShell.Exec("start D:\dir\user.bat");
Sometimes it runs, sometimes I get those errors "Expected hexadecimal digit", "Access is denied".
I'm really confused. All I'm trying to do is execute a bat file from a javascript file.
Anyone has any idea how to do it? Thank you!
var oShell = WScript.CreateObject("WScript.Shell");
oShell.Exec("D:");
oShell.Exec("cd dir");
oShell.Exec("start user.bat");
I've also tried that:
var oShell = WScript.CreateObject("WScript.Shell");
oShell.Exec("start D:\dir\user.bat");
Sometimes it runs, sometimes I get those errors "Expected hexadecimal digit", "Access is denied".
I'm really confused. All I'm trying to do is execute a bat file from a javascript file.
Anyone has any idea how to do it? Thank you!