- Start an application at system start without login
- 9 Answers 9
- How to run application automatically when Windows starts?
- 5 Answers 5
- How to make our form(application) start running when windows starts in C#?
- 5 Answers 5
- Start application at when windows Starts
- 5 Answers 5
- How to launch application at logon/startup
- 1. Using a shortcut
- 2. Using a scheduled task
Start an application at system start without login
We have a new server running and we got some new programs doing import routines. So far so good. But there is one program that is put into autostart folder. So it doesn’t run until admin logs in and it stops if we logout.
I’d like to put this one into a seperate session so it may work without any interaction by simply starting it with the task scheduler at startup. Is this the right way to do this? Is it safe if I log in later and log out?
Edit: The applications shows as a symbol in the task bar if running, it can be configured by this. Anything I must know about this if I change?
Edit: It is not my application, I cannot rewrite it as a service.
9 Answers 9
I successfully added the application by using task schelduler on startup. Login and logout will not quit the application but no symbol is shown. Please add details to my side questions and I’ll mark your answer as the accepted one.
Edit: Ended up using this one. If I have to configure, I stop the application in task manager and start it again by link. After that I quit the application and restart it by task scheduler manual start.
You need to separate your application in two.
To allow it to run without a user session, you need a windows service. That should handle all the background stuff. You can then register the service and set it to start when the system starts.
To allow it to have a UI, and show up in the notification area, you need a windows application. This will be in autostart as usual, and will communicate with the service — for example, over named pipes.
While it is still (barely) possible to run an UI application without a user session, it’s only maintained for backwards compatibility, and already shows a lot of problems. It will likely be removed altogether in the future, because it breaks quite a few contracts. Do not rely on hacks like this.
You need to run your program as a Windows Service. One way of doing it is using the sc.exe program:
You can read about it here.
I also used the task scheduler to create the application at system startup. It should be noted that if you want to use for mining, you have to disable an option in «settings» where it says that if the application lasts more than three days in a row it will end.
It really works wonderfully!
I could not get the «sc create» command to work. Instead I manually edited the registry using regedit. I added a new key in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services.
I used the following page to figure out required parameters and their values. Note that the names do not map.
Old question, but for anyone that stumbles here. Use srvany to set the program as a custom service.
Note that when you do this with for example dropbox, googledrive, etc., you will need stop the service, then open the program normally to make changes like password, updates, etc.
below is a well enough intro.
Download the tool kit here
Convert user application to Service and Register it using Regsvr32 or installutil.exe. It will start the service using SYSTEM user account. Which is a high privilege account. Note : You can`t run any Window based application. Even a Message only window.
it is a old question but I recently solved in another way.
(before I was using a scheduled-task for startup but this gave me diverse problems with lots software. )
Some programs also for diverse reasons must be run at a user level. or even inside a specific user session.
So the best way I found was to use a tool like Sysinternal/Autoruns to program the auto-logon to a specific user (it is a registry setting). and in the startup-folder of that user (or any other «autorun/autolaunch» task). run a script that first locks the screen. and next runs the other intended programs. that will run under that user profile.
so you can choose a standard user or a administrator. or even launch programs from a standard user in adminsitrator mode.
I hope will help.
This «hack» solved me many problems with startup apps.
How to run application automatically when Windows starts?
I have a console application written in VB.Net. All I want is it to run automatically when the computer starts.
5 Answers 5
Create an entry in registry under
- Start regedit.exe
- Navigate to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
- Create a new string value and give it tha title you please (it’s just for you, to rememeber what is it)
- Set the value to the full path (and params) of the EXE you want to run.
You can just simply add it to the Startup folder in the Start Menu in Windows and it will startup with the computer.
I would set it up in the task scheduler, run the scheduler from control panel / administrative tools, create a new task and set the trigger to «When the computer starts».
Or you can do it in your setup program, or write some code using Microsoft.Win32.TaskScheduler.dll that is run within the setup program.
The simplest way to achieve this would be to convert your console application into a Windows Service.
However, you could look at the Scheduled Tasks and see if there is an option to start the application when the computer starts.
I think the question here is that as a programmer how to make a program automatically run on it own when a computer starts up just like anti virus programs which automatically starts once the user has logged on his computer.
I’m also looking for the same answer like code to the program the Auto-run which the computer will read then execute the program.
If you are a vb.net user, here is the line of code I’ve manage to write to automatically write and save auto-run on a computer.
First, you will need to locate the correct place or directory in which a computer will look for the auto-run, and if you are targeting the users who use Windows XP, the directory is just Drive «C». You also have to check if there is an auto-run already there because the computer won’t store two of the same files. So if there is an auto-run, then you will just have to edit it and keep in mind that the auto-run that is already there is stored for another program. You don’t have to remove it or override it because the program that is using it will not automatically run.
On your code on form_load you first have to check if the Auto-run is existing or not, so here is how you do it. Remember, these codes will go under the Form_load
NB: all the above code you write it in one line to prevent the Errors. Now you need to write it ow here. I assumed that on Drive C there is an auto-run so let go on editing it.
That is the code but remember that in other computers your program will need permissions to read and write to a Drive so you have to grant your program the permissions that is also done in codes.
We also check if autorun has been created. If it has been created then we stop the program from always creating the autorun because that will confuse our autorun. So this will simply write once only.
Note that this is not supported on Windows 7 so I’m still trying to invent a new way or get a new way. I think the answer of Jesus r is the best answer if you are using or targeting Windows 7 or 8.
The best way to automatically do the answer of Jesus R is to first know the Default directory of the Startup folder. Then, when you are creating your installation wizard, you will simply instruct it to save your program on the Startup folder.
How to make our form(application) start running when windows starts in C#?
I have created an application using C# 3.0.I need that application to start and run continuously whenever Windows starts.After setting up and installing the application this process should happen. Please give your suggestions to do this.
5 Answers 5
What about adding the program to the start-up folder in the install? When you create your set-up project, just add a shortcut to the output from the main program to the destination PC’s start-up folder.
If you need an app to start when Windows starts and run continually, it should be a Windows Service. You won’t be able to have GUI and Windows as a part of the same app/project, you’d need to write that separately and communicate with the Service.
If you want it to run continually and not stop, a plain Windows Forms app won’t do it: the user can close it, of course. They can close a service too but you can configure in (on the Recovery tab) to restart if it ‘fails’ (is killed in Task Manager). They can still stop the service manually, though — but not as easily.
It’s a project template built into Visual Studio. Depending on what your app is doing, it’s usually best to create an instance of a Thread object, and put your logic in a loop of sorts that executed on the new thread. From the OnStart and OnStop methods of the Service thread itself, you can create the thread, or signal it to stop (or simply Abort it).
By right-clicking on the service in the designer, you can ‘Add Installer’, which means if you run installutil with the name of the application, the service will be installed and, if you set the correct properties on the Service and Installer, run automatically.
In terms of if you need a user interface — you’d have to come up with some way of the UI to talk to the service; you could use Named Pipes, Memory-Mapped Files, or you can use WCF (.NET 3.5+) with the Named Pipes/TCP provider, and call right into it.
Start application at when windows Starts
I have checked some other examples.
I am working on a winfrom. & now i am going to create its installer.
i want to start the software when windows starts & trying to use the following code.
But i am confused that where to put this code. i don’t want this code executed every time when my application starts as it will executed once when the software is installed.
shall i put check on form_Load() if the regkey is absent, & if yes then add this value to the Run.
is it correct ? i don’t want to give an option to the user & i want to start this application at the startup compulsorily.
5 Answers 5
You can create your customAction class for your installer like this: http://msdn.microsoft.com/en-us/library/d9k65z2d.aspx#Y0
Once you have this class, put your registry code in the commit section. Now, whenever your application will be installed, your application will be added to registry to run at startup.
As the others users have commented, this kind of thing should go on the installer. On the setup project you can create with Visual Studio, you can add a link to the user’s startup folder that should do the trick.
BUT
If you don’t want the user tampering with the startup folder and you absolutely want the program to start automagically with Windows, you could do as you’ve said: check for the adequate registry key everytime the program starts, and if it’s not there write it. Take into account your program will need elevated account rights for this.
BUT
Do you ABSOLUTELY need this? Are you absolutely sure you can’t offer it as an option to the final user? If I was a user to your program, didn’t want it on startup, take the effort to remove a registry key to get it out of there and then find out it’s again in the registry without my consent, I’d be pretty pissed.
How to launch application at logon/startup
If you always open the same programs after starting your computer, you might find it convenient to have them start automatically when the Windows starts. The following article explains how to launch the application at startup, when the user logon.
To achieve this, you can use two approaches:
1. Using a shortcut
Create a shortcut as explain in the create shortcut article and place it in the Start Menu -> Startup folder. For details, please check the Paths of the folders in the «Files and Folders» Page article.
The next time you start Windows, the program will run automatically.
The installer sets the StartupFolder property to the full path of the Startup folder. If a per-machine installation will be performed, then the shortcut will be available for all users. That means at each logon of any users, the application will start since it is placed in a public location:
If a per-user installation will be performed, then the shorcut will be available only for the user that installed the application. The StartupFolder property being set with the following value:
You can set the installation type, per-user or per-machine in the Install Parameters view.
2. Using a scheduled task
You can launch your application when the user logon using a scheduled task. In the Scheduled Tasks page and add the application from your project to the Windows Task Scheduler.
Using the [ New Task ] toolbar button or the “New Task” context menu item, the Edit Task dialog will be displayed allowing you to specify the task settings. In the Schedule tab you can specify the task to be executed at user logon. For this, you can select the At Logon option from the drop-down list.