Reputation: 11
I have the following bat file:
@echo off
start /min powershell "& 'C:\Admin\c.ps1'"
exit
I don't want to display the powershell window as this is an administrative script that runs on startup.
I was under the impression that using start /min
will solve it, but It's still displaying.
Upvotes: 1
Views: 5341
Reputation: 31221
You can use a VBScript to stop the window from appearing at all.
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("C:\Admin\c.ps1"), 0, True
Plus you can use this instead of the batch file, so there will be no cmd window either.
Hope this helps.
Upvotes: 0
Reputation: 29339
START
command has option /b
to start an application without creating a new window.
try
start /b powershell "& 'C:\Admin\c.ps1'"
Upvotes: 1
Reputation: 126722
PowrShell has a switch to launch itself hideen. That said, the console may be visible for a short period of time until it disappears. Since this is an administrative script, I would also recommend using the NonInteractive switch to prevent someone from interfering with it
@echo off
powershell -NonInteractive -File C:\Admin\c.ps1
exit
If you can't afford the console to be visible at all, consider using a vbs file to launch powershell:
Set oShell = CreateObject("WSCript.Shell")
oShell.Run("powershell -NonInteractive -File C:\Admin\c.ps1",0,False)
Upvotes: 3
Reputation: 930
If you use 'Task Scheduler', 'Run Once On Startup', there is an option to hide windows like this.
Upvotes: 1