Hey guys, I'm trying to install an app on a windows server that is always on, but I'm running into problems. I've heard that I shouldn't make it a windows service (and would personally rather have a dialog app so I can see progress, etc) so I'm trying to use task scheduler. However, task scheduler keeps trying to close my app prematurely when it should only open it and leave it open.
Any ideas how I could have a dialog app run on startup (and stay running) on my server?
Thank you
You should make a Windows Service; it's the only reliable way to do this.
Otherwise, you will run into problems if, for example, the user logs off.
If you want UI, you can make a separate GUI that communicates with the service (probably using WCF).
You can do it with a Scheduled Task which wont have problems with users logging on/off.
- Open Task Scheduler, Windows Key + R
Taskschd.msc
- Click Action menu > Create Task
- Change the User to a Administrator or preferably a Service Account:
- Set At Log On:
- Set a program to start:
I prefer to create a task in the Task Scheduler and set the trigger as "On Startup", but you can also use Startup Scripts.
You can also use the Local Group Policy Editor (executing gpedit) and add a Startup script. Copying the steps from http://technet.microsoft.com/en-us/library/cc770556.aspx so that if they take it down, it still can be found at SO.
To assign computer startup scripts
- Open the Local Group Policy Editor.
- In the console tree, click Scripts (Startup/Shutdown). The path is Computer Configuration\Windows Settings\Scripts (Startup/Shutdown).
- In the results pane, double-click Startup.
- In the Startup Properties dialog box, click Add.
- In the Add a Script dialog box, do the following:
- In the Script Name box, type the path to the script, or click Browse to search for the script file in the Netlogon shared folder on the domain controller.
- In the Script Parameters box, type any parameters that you want, the same way as you would type them on the command line. For example, if your script includes parameters called //logo (display banner) and //I (interactive mode), type //logo //I.
- In the Startup Properties dialog box, specify the options that you want:
- Startup Scripts for <Group Policy object>: Lists all the scripts that currently are assigned to the selected Group Policy object (GPO). If you assign multiple scripts, the scripts are processed in the order that you specify. To move a script up in the list, click it and then click Up. To move a script down in the list, click it and then click Down.
- Add: Opens the Add a Script dialog box, where you can specify any additional scripts to use.
- Edit: Opens the Edit Script dialog box, where you can modify script information, such as name and parameters.
- Remove: Removes the selected script from the Startup Scripts list.
- Show Files: Displays the script files that are stored in the selected GPO.
It's very old question, but for those who coming here via Google:
start command prompt
type shell:Startup
This will open a window in the otherwise hidden AppData path for the Startmenu/Programs/Startup -> Add a shortcut to the executable for the program you want to start.
This will of course only apply to the logon account that you're using at the time.
For all users type shell:Common Startup