K B
asked on
Powershell script that runs at first boot only
I would like a Powershell script to run at initial boot only please. - as an administrator.
Once, it runs successfully, I would like some sort of flag incremented so that it will not run again.
This is not Domain Joined, so GPOs are not in the picture.
Thank you!
Once, it runs successfully, I would like some sort of flag incremented so that it will not run again.
This is not Domain Joined, so GPOs are not in the picture.
Thank you!
ASKER
thank you for your reply Qlemo!
That makes sense. So how would I fire off the script at boot (in your opinion).
That makes sense. So how would I fire off the script at boot (in your opinion).
ASKER
I am realizing that I would like this to run before anyone logs in. Is that possible?
That can be done with a scheduled task. Pick "Create a Basic Task" from the menu, set it to start "When the computer starts".
As Program/Script, use "Powershell.exe", as arguments (obviously adjusting the path inside the single quotes)
If someone's fast with the logon, he might make it before it runs, but unless he's using the same account you used for the task, he won't see anything, so the success depends on what it is you want to achieve with the script.
As Program/Script, use "Powershell.exe", as arguments (obviously adjusting the path inside the single quotes)
-ExecutionPolicy Bypass -Command "& 'C:\Wherever\script.ps1'"
In the "Finish" dialog, check "Open the Properties dialog ...", click "Finish", then set the user and password (you can use SYSTEM as well, no password), change the radio button to "Run whether user is logged on or not" (if not using SYSTEM), and check the box "Run with highest privileges".If someone's fast with the logon, he might make it before it runs, but unless he's using the same account you used for the task, he won't see anything, so the success depends on what it is you want to achieve with the script.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Instead of the reg key we could remove or disable the scheduled task after execution, which I would prefer.
ASKER
Perfect!!
How do you think you can get the script running on a boot in the first place?