2013-03-07 74 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 

这样,当脚本运行/完成时,脚本不会执行任何操作。