execute batchfile

M

Mark

Hello,

I can execute a batch with the VBA Shell( "cmd.exe /c mypath\my.bat" )
command, but the script does not run in his directory; how I can run my
batch in his own directory - I do not want to handle this within the script
by "cd mypath".

Thanks and regards
Mark
 
M

Michael Bednarek

I can execute a batch with the VBA Shell( "cmd.exe /c mypath\my.bat" )
command, but the script does not run in his directory; how I can run my
batch in his own directory - I do not want to handle this within the script
by "cd mypath".

You should. It is good practice that a batch file either uses a syntax
which doesn't rely on any particular current directory (by using fully
qualified filenames), or establishes a current directory.

Anyway, if you want to give the CMD process a specific current
directory, try this: "cmd.exe /c cd /d mypath && mypath\my.bat".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top