www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Run program at startup

reply "SaltySugar" <Butkustomas777 gmail.com> writes:
How to run my program when computer starts?
Feb 08 2013
parent reply "Dicebot" <m.strashun gmail.com> writes:
On Friday, 8 February 2013 at 15:06:24 UTC, SaltySugar wrote:
 How to run my program when computer starts?
This question is irrelevant to D and is operating system specific. It is better suited for stackoverflow & Co.
Feb 08 2013
parent reply "rumbu" <rumbu rumbu.ro> writes:
On Friday, 8 February 2013 at 15:08:06 UTC, Dicebot wrote:
 On Friday, 8 February 2013 at 15:06:24 UTC, SaltySugar wrote:
 How to run my program when computer starts?
This question is irrelevant to D and is operating system specific. It is better suited for stackoverflow & Co.
If you want D to become popular, that's not an appropiate answer in the d.learn section. I'm sure that if someone will ask the redirect to an external forum. --- To run at startup for all users, the most used way for a program to do this is to create a string value in the following registry keys: - HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Current Version\Run if the program will run every time. - HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Current Version\RunOnce if the program will run once. In D, this will look like this: import std.windows.registry; void runMeAtStartupEveryTime(string exeName) { auto key = Registry.localMachine.getKey(`SOFTWARE\Microsoft\Windows\CurrentVersion\Run`, REGSAM.KEY_SET_VALUE); key.setValue("runme", exeName); } int main(string[] args) { runMeAtStartupEveryTime(args[0]); return 0; } Of course, you must have the appropriate rights to do this. This approach is Windows specific, I don't have any hint about another OS.
Feb 08 2013
parent "bearophile" <bearophileHUGS lycos.com> writes:
rumbu:

 If you want D to become popular, that's not an appropiate 
 answer in the d.learn section. I'm sure that if someone will 

 answer, not a redirect to an external forum.
I agree that it's important to be gentle. (I remember the C newsgroups where many questions received rude answers like: "Not a C Standard question" (because the C standard leaves many essential things to OS-specific functions or compiler-specific implementations)). Bye, bearophile
Feb 08 2013