2013-03-07 76 views
0

我正在使用一些調用.bat文件的powershell按鈕。我環顧四周,但它似乎只是反過來工作。我試圖找出從powershell按鈕調用.bat文件的語法。這似乎從命令行工作,但我有我的按鈕內使用它的問題。任何消化?從powershell按鈕單擊事件執行.bat文件

$StartButton = New-Object System.Windows.Forms.Button 
$StartButton.Location = New-Object System.Drawing.Size(170, 450) 
$StartButton.Size = New-Object System.Drawing.Size(125,43) 
$StartButton.Font = New-Object System.Drawing.Font("Courier New", "10.5") 
$StartButton.Text = "Start Tuner" 
$StartButton.Add_Click(invoke-command{C:\temp\Map.bat}) 
$tunerForm.Controls.Add($StartButton) 

非常感謝任何事情。

回答

1

對不起傢伙..我找到了答案..調用表達式「CMD /cc:\path\to\batch\file.bat」

對不起......

+0

我的虛驚 – Mikey 2013-03-07 20:50:00

2

您還可以使用啓動 - 進程和 - 等待

Start-Process myBatch.bat -wait 

這樣,當腳本運行/完成時,腳本不會執行任何操作。