I have a executable file that I need to run when a machine starts. The scenario is that I need to write install.ps1 and uninstall.ps1. install.ps1 will tell the machine to run my executable everytime the computer starts. uninstall.ps1 will tell the machine not to run that executable. I m looking for how write install.ps1 and what to write in that so that it runs the executable. Also is there any way that I can put a timer in the .ps1 file to check if the executable is executing or not?
2 Answers
You could use Scheduled Task to start the executable. Something like:
schtasks.exe /Create /TN myTask /SC ONSTART /TR notepad.exe
It will start notepad on login according to: http://poshtips.com/2011/04/07/use-powershell-to-create-a-scheduled-task/