Restarting my app at bootup
-
MachineCode
- Addict

- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Restarting my app at bootup
I know how to make my app start at bootup, no problem. But, this means the PC has to have a single user account with no password, otherwise my app can't run because no user is logged in when the PC boots. How to get around this problem? Note: The reason I need this, is because my PC rebooted by itself while I was out, and thus my app wasn't running anymore when I got home. I want to avoid this happening in future.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
-
jesperbrannmark
- Enthusiast

- Posts: 536
- Joined: Mon Feb 16, 2009 10:42 am
- Location: sweden
- Contact:
Re: Restarting my app at bootup
Sound like you want to install your program executable as a service.
I have never tried this myself, but a quick google search gave me:
http://www.qweas.com/download/system/de ... ervice.htm
http://www.governmentsecurity.org/forum ... opic=11979
I have never tried this myself, but a quick google search gave me:
http://www.qweas.com/download/system/de ... ervice.htm
http://www.governmentsecurity.org/forum ... opic=11979
http://smallvoid.com/article/winnt-services-srvany.htmlreg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run /v ServiceName /d "c:\path\to\service\file\exe"
(dont blame me if its crap programs, i havnt tried them)Instsrv.exe MyService C:\Srvany.exe
[HKEY_LOCAL_MACHINE \SYSTEM \CurrentControlSet \Services \MyService \Parameters]
Application = "C:\MyApp.exe"
-
GoodNPlenty
- Enthusiast

- Posts: 112
- Joined: Wed May 13, 2009 8:38 am
- Location: Arizona, USA
Re: Restarting my app at bootup
You might try using the Group Policy Editor to launch your app under Startup.
Click "Start" "Run" or "Search programs and files" then type gpedit.msc
In the console tree, click "Computer Configuration"->"Windows Settings"
Double click "Scripts(Startup/Shutdown)" then Double click "Startup" in right pane.
Click the "Add" button and browse to your program.
In Script Parameters, type any comand line arguments that you want and then click "Ok"
Click "Ok" again.
Exit out of all the Group Policy Editor.
Now when Windows boots your app will run for you before the user logs on.
Note: Your app will run under the Local System account, and have the full rights to run as Local System.
Click "Start" "Run" or "Search programs and files" then type gpedit.msc
In the console tree, click "Computer Configuration"->"Windows Settings"
Double click "Scripts(Startup/Shutdown)" then Double click "Startup" in right pane.
Click the "Add" button and browse to your program.
In Script Parameters, type any comand line arguments that you want and then click "Ok"
Click "Ok" again.
Exit out of all the Group Policy Editor.
Now when Windows boots your app will run for you before the user logs on.
Note: Your app will run under the Local System account, and have the full rights to run as Local System.
-
MachineCode
- Addict

- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: Restarting my app at bootup
Thanks for all replies, I will check them out.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
- netmaestro
- PureBasic Bullfrog

- Posts: 8453
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Restarting my app at bootup
Here is some code from Joakim Christiansen. Note the comment for the first line of the procedure:
Code: Select all
Procedure StartWithWindows(State.b)
Protected Key.l = #HKEY_CURRENT_USER ;or #HKEY_LOCAL_MACHINE for every user on the machine
Protected Path.s = "Software\Microsoft\Windows\CurrentVersion\Run" ;or RunOnce if you just want to run it once
Protected Value.s = "GmailEnhancer" ;Change into the name of your program
Protected String.s = Chr(34)+ProgramFilename()+Chr(34) ;Path of your program
Protected CurKey.l
If State
RegCreateKey_(Key,@Path,@CurKey)
RegSetValueEx_(CurKey,@Value,0,#REG_SZ,@String,Len(String))
Else
RegOpenKey_(Key,@Path,@CurKey)
RegDeleteValue_(CurKey,@Value)
EndIf
RegCloseKey_(CurKey)
EndProcedure BERESHEIT
-
MachineCode
- Addict

- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: Restarting my app at bootup
Thanks, but Joakim's code doesn't work because no user is logged in after a reboot. Plus, only admins can set #HKEY_LOCAL_MACHINE, and my users may be under a limited account.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!