Hi I normally just right click and edit my scripts, then just run them through PowerShell ISE using the green arrow.
But I have a need to start /wait a script in a batch file. I want my script to run and then have the rest of the batch file to wait till the PowerShell script is closed. (Hence the start /wait)
And it works fine, but my issue is this: it opens up fine but no matter if I choose the letters by the options or the numbers I set in the choice script it will either restart or close out depending on the choice.
**I had nice pictures to go with this but I don't have enough rep so here is a bit of code :(
powershell.exe Set-ExecutionPolicy -ExecutionPolicy Bypass
#Main Choice Script
$IP = New-Object System.Management.Automation.Host.ChoiceDescription '&Edit IP', 'Change IP
Address'
$Intro= New-Object System.Management.Automation.Host.ChoiceDescription '&Change Introscreen',
'Change Introscreen'
$Gecko = New-Object System.Management.Automation.Host.ChoiceDescription '&Replace Gecko',
'Change Gecko Folder'
$PCName = New-Object System.Management.Automation.Host.ChoiceDescription '&Host Name', 'Fix
Host Name'
$Firewall = New-Object System.Management.Automation.Host.ChoiceDescription '&Firewall
Settings', 'Fix Firewall Setting'
$Close = New-Object System.Management.Automation.Host.ChoiceDescription '&Close', 'Exit'
$options = [System.Management.Automation.Host.ChoiceDescription[]]
($IP,$Intro,$Gecko,$PCName,$Firewall,$Close)
$title = 'IT Tool'
$message = 'What do you want to do?'
$result = $host.ui.PromptForChoice($title, $message, $options,-1)
switch ('$result')
{
0 { "IP" }
1 { "Intro" }
2 { "Gecko" }
3 { "PCName" }
4 { "Firewall" }
5 { "Close" }
}
I cant seem to get the options to function right, I'm thinking:
- CMD is too basic to open a prompt for choice window.
- My code isn't setup to run outside ISE
** I'm fine that the cmd window is just text and not a popup, I just would like it to work.
Any help or tips would be appreciated.
whileloop, then usebreakwhen you want it to end.start /waitto run a PowerShell command or file, the next command should not run until that command has reported that it has finished. Are you wanting the PowerShell command or file to run in a completely separate console window? as opposed to the cmd.exe window your batch file is already running within.