Alex Rivera | Logout

Can we run a batch file (.bat) from the shared path

Asked 2011-09-21T17:23:29.063
9

I have a shared path (like //servername/c$/batches/) where all my batch files are located now I am writing an web application in C# to run .bat files from that application. I know way to do it when I have a physical path. But here I dont have a physical path. Is it possible to do it.

EDIT# 1

I execute my bat files just by double clicking on them or open the cmd progam on the physical server and then navigate to the drive and execute the bat file.

EDIT #2

when I put UNC path the get the following error

I getting an error myprogram.exe is not recognized as an internal or external command operable program or batch file. 9009

Edit
Report

1 Answer

0

Apparently, you do have a current-directory issue.
The .bat file is trying to run myprogram.exe from the current directory.

You can make a wrapper batch file on your local machine that maps the network share:

pushd \\server\c$\dir
call filename.bat
popd

You can put this wrapper file anywhere, then call it from your code.

answered 2011-09-21T17:38:50.807

Your Answer