Gautam
Gautam

Reputation: 1740

Create a powershell script to run a executable at startup

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?

Upvotes: 0

Views: 568

Answers (2)

user1755942
user1755942

Reputation:

Instead of writing powerscripts you can write a console app that can put your executable file to run at startup using registry? Similarly you can write uninstall.exe that will remove the above said entry from registry. Simple and easy.. isn't it?

Upvotes: 1

steffenhk
steffenhk

Reputation: 764

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/

Upvotes: 0

Related Questions