LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Closed Thread
  Search this Thread
Old 08-31-2004, 03:26 AM   #1
cppkid
Member
 
Registered: Jul 2004
Location: Pakistan
Distribution: Ubuntu
Posts: 185

Rep: Reputation: 30
Start a program at boot time


Please its urgent, I have posted it before but i was unable to write the rc script, and don't know how to pass the program name to that script. Please anybody witre this function for me, I hope it will be not more than a few lines of code. I want a function that takes the program name and start that program name at boot time. I have written it in Visual C++ and its code is given, Please Help!!!!
The code for Windows is :-

Code:
int StartAtBootTime(const char *subkey,const char *destpath)
{
int nRet;
char msgbuf[GEN_LEN+GEN_LEN+1];
HKEY hKey;
DWORD dw;
char skey[GEN_LEN+1];
char exepath[GEN_LEN+GEN_LEN+1];

	strncpy(exepath,destpath,GEN_LEN+GEN_LEN);
	strncat(exepath,subkey,GEN_LEN+GEN_LEN);
	strncat(exepath,".exe",GEN_LEN+GEN_LEN);

	strncpy(skey,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",GEN_LEN);
	nRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE, skey, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dw);
	if(nRet != ERROR_SUCCESS)
	{
		_snprintf(msgbuf,GEN_LEN+GEN_LEN,"Unable to access %s",skey);
		
		return -1;
	}
	nRet = RegSetValueEx(hKey,subkey, 0, REG_SZ,(BYTE *) exepath,strlen(exepath));
	if(nRet != ERROR_SUCCESS)
	{
		_snprintf(msgbuf,GEN_LEN+GEN_LEN,"Unable set info to start %s at boot time",exepath);
		
		return -2;
	}
	_snprintf(msgbuf,GEN_LEN+GEN_LEN,"%s will be started at boot time",exepath);
	

	return 1;
}
 
Old 08-31-2004, 04:30 AM   #2
Proud
Senior Member
 
Registered: Dec 2002
Location: England
Distribution: Used to use Mandrake/Mandriva
Posts: 2,794

Rep: Reputation: 116Reputation: 116
http://www.linuxquestions.org/questi...hreadid=224632

Last edited by Proud; 08-31-2004 at 04:31 AM.
 
Old 08-31-2004, 04:53 AM   #3
cppkid
Member
 
Registered: Jul 2004
Location: Pakistan
Distribution: Ubuntu
Posts: 185

Original Poster
Rep: Reputation: 30
I am sorry for re-posting. I just get a little frustated coz that was what i need very very urgent and i don't know what else to do else than asking it on LQ.
I'll take care next time.!
Thanks.
 
Old 08-31-2004, 09:33 AM   #4
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Please be patient. Free site equals members answer other members questions in their own spare time, be considerate to the forums and its members.

Don't double post, its against our rules.

If you don't get any replies, feel free to bump it after at least 24 hours has passed by.

http://www.linuxquestions.org/rules.php
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make a program run at start up time. TruongAn Linux - Software 22 10-26-2005 06:50 PM
Start Apache at boot-time alexthedon Linux - Networking 1 06-26-2005 03:59 PM
Start VNC at boot time hlpboplz Linux - Newbie 13 05-25-2005 03:55 PM
How to start a program at bootup time? shilpig Linux - Software 6 09-28-2004 01:45 PM
i want to run a script or program at boot time!! FreakboY Linux - Newbie 9 10-12-2003 08:03 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration