Reputation: 11
Currently I've got my PowerShell script on the desktop named Chrome with a Chrome logo on it. They launch that, it opens chrome for them to use but if you tab out you'll see a PowerShell script idle counting until it reaches the terminate period.
Issue - Small business owner that has several computers employees use for web (chrome) based duties day to day. Employees often leave without logging out and closing their browser.
My Solution - Run chrome in incognito by default
While this works, they are now leaving their incognito tab open and not closing it to prevent logging out...
My Solution - deployed powershell script to close chrome after a set period of idle mouse and KB.
WHY I'M HERE - Is there any way to prevent them from closing out of my powershell script? Also is there a way to make it less obvious a giant powershell icon in the dock?
Upvotes: 1
Views: 1373
Reputation: 438198
This answer provides an overview of launching applications hidden.
A non-third-party solution that requires a helper VBScript, however, is described in this answer.
Assuming you have created such a script and named it runHidden.vbs
and placed it in C:\path\to\HelperVBScript
, you can create your shortcut file with a command line such as the following:
wscript.exe C:\path\to\HelperVBScript\runHidden.vbs powershell.exe -file c:\path\to\your\script.ps1
This will launch your PowerShell script (.ps1
) invisibly, while allowing it to launch GUI applications such as Chrome visible - and only the latter will appear in the taskbar.
Upvotes: 1
Reputation: 1
My first thought would be to have it run as a job when the computer is logged in. Look into launching your script as a scheduled task with the command Start-Job
.
Example:
Start-Job -ScriptBlock {### YOUR CODE HERE ###}
Then, you'd need to create a scheduled task to launch this script at login. Here's a guide on how to do that: https://blog.netwrix.com/2018/07/03/how-to-automate-powershell-scripts-with-task-scheduler/
Upvotes: 0