Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I have been looking all day trying to find a way to do this. I need to run a Batch file which is held on a server, the file path begins with a IP Address which DOS doesn't like. So i found the pushd command which assigns a temp drive letter from which you can run the Batch File.

If i was simply running a normal program or file i would use:

Dim proc As Process    <br />
proc = Process.Start("c:\BatchFile.bat")   <br />
proc.WaitForExit()


but my file path is e.g. \\10.10.10.1\Public\Folder\BatchFile.bat

running from a command prompt if i type

pushd \\10.10.10.1\Public\Folder\ (Enter)
BatchFile.bat

the Batch File runs fine, but i need to be able to do this from within VB.NET and the main program still needs to wait for the batch file to run and the cmd prompt to close before continuing.

Any suggestions would be excellent or if i haven't explained this well enough let me know

Thanks
Posted
Updated 21-Jun-11 4:39am
v2

Have you tried:

Dim proc as Process = Process.Start("\\10.10.10.1\Public\Folder\BatchFile.bat")
proc.WaitForExit()
 
Share this answer
 
Comments
STP_Martin 21-Jun-11 12:37pm    
Yea i tried that and the cmd flashes quickly and when i finally managed to catch the error it said it cannot use UNC addresses thats when i realised you can't use IP addresses directly in cmd and then i found out about the pushd command.
You could get this to work with a local batch file that does the PUSHD bit and then calls the remote file.

e.g.
SET REMOTEPATH=\\10.10.10.1\Public\Folder
PUSHD %REMOTEPATH%
  CALL BatchFile.bat
POPD


Alan.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900