PDA

View Full Version : how to start a service on computer startup.



Ketan Shah
1st June 2011, 13:33
Hii,
In my application I am writing a code that starts a particular service “for eg:- say MySql.” on computer startup….Can any 1 tel me how can i do this and using which Qt class, its possible..
please help..

squidge
1st June 2011, 14:09
This is OS dependent and normally hamdled by the OS. For example, on Windows you would install mySql as a service and it would be loaded on startup for you.

Or do you mean you just want to load an application from within yours? If so, see QProcess

Ketan Shah
1st June 2011, 14:19
I just want to add a checkbox in my application,such that on checking that checkbox the particular service should be started on windows startup and on unchecking the checkbox, the service should not start on windows startup..

squidge
1st June 2011, 19:08
Typically you would use InstallUtil (http://msdn.microsoft.com/en-us/library/50614e95%28v=vs.80%29.aspx) which would request the OS installer tool to install your application as a service.

ChrisW67
2nd June 2011, 00:46
Your program will generally need administrator privilege to start/stop/modify Windows services.

If all you want is for the user-space program to start when the user logs in then that is a different question that can be addressed by placing a shortcut into the user's Start Menu Programs/Startup folder (or Vista/Win7 equivalent)

Ketan Shah
3rd June 2011, 08:10
But how can I create the shortcut of the service and place it in the startup folder...
Is there any way to do that using any Qt class....

Santosh Reddy
3rd June 2011, 08:15
Yes, you can use QFile::Link() to create a shortcut and then place it in the startup path, you may need admin right for the program to do so, as mentioned by ChrisW67 earlier