No need to move the mouse to search for a program.
You can press on Win+S to get to the search bar in the Taskbar, but it looks like it has more than a regular search bar, first of all, you can integrate additional plugin, you can also see here .
I wrote the following PS script:
Enable-NetFirewallRule -DisplayName "Network Discovery"; exit
If you paste that code to a PS console with, run as an admin it will execute the command and exit (close the window) powershell.
When I run this script through a shortcut the window stays open and it doesn’t exit. The shortcut runs powershell.exe as admin and then the shortcut points to the location of the script with some parameters beforehand.
The behaviour is specific to the exit command. If I’m running let’s say “ipconfig” after the semicolon it runs just fine.
Answers are greatly appreciated!
The behavior makes sense, you can’t tell a Script to Exit something that it is not itself - the Powershell window opened by the shortcut - if you just run the ps1 file from the shortcut it will Exit, but then you can’t put your arguments, are they needed?)
I’ve seen someone using a workaround to shut the PowerShell window from within the script using ($PID is a variable for the current PowerShell session):
stop-process -Id $PID
@Knaper-Yaden Thanks for you reply. I just realised that I’ve added the -noexit parameter by mistake… I think that is why it ignores exit…