Create a .bat file. ex: MyApp.bat
Call powershell script from batch file.
Now create a PS1 script ex" MyScript.PS1
Calling exe from Powershell
Call powershell script from batch file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Set exePath="C:\My.exe" | |
Echo "Call PS1" | |
PowerShell.exe Set-ExecutionPolicy RemoteSigned; "C:\MyScript.PS1" -exePath %exePath% | |
Echo "End PS1" | |
PAUSE |
Now create a PS1 script ex" MyScript.PS1
Calling exe from Powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param | |
( | |
[string]$exePath = $null | |
) | |
write-host “Calling exe” | |
$startTime = Get-Date | |
Write-Host "Start time " + $startTime.ToString("u") | |
$exePath = $exePath | |
& $exePath | |
$endTime = Get-Date | |
Write-Host "End time " + $endTime.ToString("u") | |
write-host “End exe” |