问题描述
嗨
我整天都在寻找设法做到这一点的方法.我需要运行服务器上保存的批处理文件,文件路径以DOS不喜欢的IP地址开头.因此,我发现了pushd命令,该命令分配了一个临时驱动器号,您可以从中运行批处理文件.
如果我只是运行普通程序或文件,我将使用:
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()
但是我的文件路径是\\ 10.10.10.1 \ Public \ Folder \ BatchFile.bat
如果我键入
,则从命令提示符运行
推入\\ 10.10.10.1 \ Public \ Folder \(Enter)
BatchFile.bat
批处理文件运行正常,但是我需要能够在VB.NET中执行此操作,并且主程序仍需要等待批处理文件运行并且cmd提示关闭才能继续.
任何建议都是很好的,或者如果我对这个解释不够好,请告诉我
谢谢
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
推荐答案
Dim proc as Process = Process.Start("\\10.10.10.1\Public\Folder\BatchFile.bat")
proc.WaitForExit()
SET REMOTEPATH=\\10.10.10.1\Public\Folder
PUSHD %REMOTEPATH%
CALL BatchFile.bat
POPD
艾伦.
Alan.
这篇关于使用UNC运行批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!