Reputation: 2314
I would like to start a powershell script if the Server turns on. No dependency on the user and if a certain user logs out the program should continue working. I tried an entry in the registry with the HKey_localMachine but my program won't continue working if a user logs off. Maybe there is a solution with the Task Scheduler?
Upvotes: 1
Views: 5724
Reputation: 594
One shot in the dark is to have a scheduled task run a program/cmd.exe/powershell script as system on startup or user logon.
The command for starting on startup should be this:
schtasks /Create /TN taskName /SC onstart /TR powerShellScript.ext /RU system
Where powerShellScript.ext
is replaced by whatever your script or other file is.
That should run whatever replaces powerShellScript.ext
as system, thus preserving the process even if no users are logged on.
Another option is to launch the script once using a service as soon as it's started, but I don't have experience with that.
This might not work depending on how the file is launched. the most reliable method is to launch an executable and set the launch options to load whatever it is that you actually want.
Upvotes: 0
Reputation: 473
Task scheduler is an option. Maybe run it with system-rights instead of admin
Upvotes: 1