[英]How to make a batch script to run commands on a remote machine using credentials
[英]batch script commands not working remotely
我有一個使用asp.net的網站,我正在嘗試創建一個批處理腳本並運行它。
我正在使用它來獲取tfs工作區的最新文件
.bat只有
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"
tf get "workspacePath" /force /recursive
當我通過單擊.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()
, .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"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.