批处理脚本命令不能远程工作

本文关键字:工作 程工作 脚本 命令 不能 批处理 | 更新日期: 2023-09-27 18:07:56

我有一个使用asp.net的网站,我正在尝试创建一个批处理脚本并运行它。

我用它来获取tfs工作空间的最新文件

.bat中只有

call "C:'Program Files (x86)'Microsoft Visual Studio 12.0'VC'vcvarsall.bat"
tf get "workspacePath" /force /recursive

当我在远程服务器上通过点击.bat本身来运行它时,它工作得很好,并且做了我需要它做的一切。

当我试图通过网站使用它时,它不起作用。

我确认它确实通过在bat的位置添加一个随机的.txt文件来读取并尝试执行脚本,并让脚本删除它,这在整个网站都有效。

我有很多次通过我的网站运行批处理脚本,但对于这个特定的例子,它不工作。

我已经试过通过…

Process.Start(@"filepath'getStuff.bat");

我也试过使用psExec

绕过批处理脚本
Process p = new Process();
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.RedirectStandardOutput = true;
    p.StartInfo.FileName = @"path'PsExec.exe";
    p.StartInfo.Arguments = @"''vdvws052 ""C:'Program Files (x86)'Microsoft Visual Studio 12.0'Common7'IDE'TF.exe"" get ""workspacePath"" /force /recursive";
    p.Start();

我尝试过的每一种方式我也添加了一个.WaitForExit()以防万一,但这也没有帮助

批处理脚本命令不能远程工作

使用&为每条命令签名。

,用于组合两个(或多个)命令。执行command1,然后执行command2

""C:'Program Files (x86)'Microsoft Visual Studio 12.0'Common7'IDE'TF.exe"" & get ""workspacePath"" /force /recursive"

,,条件组合。如果command1成功完成,则执行command2

""C:'Program Files (x86)'Microsoft Visual Studio 12.0'Common7'IDE'TF.exe"" && get ""workspacePath"" /force /recursive"