0

I was working with some powershell button that calls a .bat file. I have looked around but it only appears to work the other way around. I'm trying to figure out the syntax to call a .bat file from powershell button. This seems to work from command line, but I'm having issues with using it within my button. Any sugestions?

$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)

Thanks anything is highly appreciated.

2 Answers 2

2

You can also use Start-Process and -wait

Start-Process myBatch.bat -wait

That way, your script does not do anything else while that script runs / completes.

Sign up to request clarification or add additional context in comments.

Comments

1

Sorry guys.. I found the answer.. Invoke-Expression "cmd /c c:\path\to\batch\file.bat"

Sorry...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.