LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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

Reply
 
Search this Thread
Old 09-03-2006, 09:37 PM   #1
b0nd
Senior Member
 
Registered: Jan 2005
Distribution: Slackware, BackTrack, Windows XP
Posts: 1,020

Rep: Reputation: 45
how to write a batch file to make a program run during boot up in windows???


Hello all,
i'm not much familiar with batch file programming. Know this only that simple dos command prompt commands are to be written in it.

so i made a .txt file and its content was

Quote:
copy abc.txt C:\
saved it with .bat extension.
the file abc.txt and the batch files were in same directory, so when i executed the .bat file by clicking mouse on it, it copied the abc.txt to C:\.
Fine upto here...

now my questions is that what should be written in this batch file to make it run some executable when the system boots ???

i.e i want my executable to be here:

Quote:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]

i'll keep both, the .exe and .bat in the same directory so that i won't have to specify the path of the .exe file.

EDIT: In a nutshell: Whatever place that .bat and .exe be (but they must b in the same directory), .bat should make that .exe run and make its entry somewhere such that .exe file runs everytime i boot the machine.


regards

Last edited by b0nd; 09-03-2006 at 09:50 PM.
 
Old 09-03-2006, 09:51 PM   #2
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 600

Rep: Reputation: 126Reputation: 126
According to the OS version, the interface and naming might change. Also, it isn't necessary to know the registry folder.

In Start -- settings -- taskbar and start menu, look for a "folder" (need not be a directory) called as "startup". Puta link to your programme there being sure to specify that the startup folder os your folder.

End
 
Old 09-03-2006, 10:00 PM   #3
b0nd
Senior Member
 
Registered: Jan 2005
Distribution: Slackware, BackTrack, Windows XP
Posts: 1,020

Original Poster
Rep: Reputation: 45
Quote:
Originally Posted by AnanthaP
According to the OS version, the interface and naming might change. Also, it isn't necessary to know the registry folder.

In Start -- settings -- taskbar and start menu, look for a "folder" (need not be a directory) called as "startup". Puta link to your programme there being sure to specify that the startup folder os your folder.

End
Hi,
I think you are talking about this startup folder (windows XP)
Quote:
C/Documents and Settings/Bond/Start Menu/Programs/Startup
But i've seen entries in
Quote:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]
which makes the programs run during boot up.
So is not there any way for a .bat file to put something there to let the .exe run everytime the machine boots up ???


regards
 
Old 09-03-2006, 10:02 PM   #4
sn68
Member
 
Registered: Oct 2005
Distribution: FC5
Posts: 338

Rep: Reputation: 30
Re : how to write a batch file to make a program run during boot up in windows???

An alternative way is

open command prompt by start -> run -> cmd & enter
cd into c:\ drive
type edit autoexec.bat & enter
a text editor will open where you can write commands and then save the file
the commands will be run during startup
for instance to run aaaaa.exe on startup in c:\aa\bb dir
add the following line
C:\aa\bb\aaaaa.exe

Last edited by sn68; 09-03-2006 at 10:05 PM.
 
Old 09-03-2006, 10:16 PM   #5
b0nd
Senior Member
 
Registered: Jan 2005
Distribution: Slackware, BackTrack, Windows XP
Posts: 1,020

Original Poster
Rep: Reputation: 45
Thanks for the responses.
I appreciate your ideas. But i'm looking something else....something related with [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]

regards
 
Old 09-04-2006, 12:09 AM   #6
lurko
Member
 
Registered: Jun 2006
Location: Ontario, Canada
Distribution: Debian
Posts: 448

Rep: Reputation: 35
in regedit, browse to [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]
edit: or [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run] /edit

right click in the part of the window displaying the keys contained in ...\Run

select New-->String Value

name it whatever you want

right click the new value, and select Modify

enter the path to your batch file in the "Value Data" field. edit: or just directly to the exe /edit

voila!

Last edited by lurko; 09-04-2006 at 12:10 AM.
 
Old 09-04-2006, 05:25 AM   #7
b0nd
Senior Member
 
Registered: Jan 2005
Distribution: Slackware, BackTrack, Windows XP
Posts: 1,020

Original Poster
Rep: Reputation: 45
Quote:
Originally Posted by lurko
in regedit, browse to [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]
edit: or [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run] /edit

right click in the part of the window displaying the keys contained in ...\Run

select New-->String Value

name it whatever you want

right click the new value, and select Modify

enter the path to your batch file in the "Value Data" field. edit: or just directly to the exe /edit

voila!
hi,
the same thing i wud like to implement using programming and not manually.

regards
 
Old 09-04-2006, 06:16 AM   #8
exman
LQ Newbie
 
Registered: May 2006
Location: Germany, BS
Distribution: Debian Kernel 2.6.15, Kubuntu Dapper
Posts: 24

Rep: Reputation: 15
Hi,
for C/C++ you should have a look at this site:
http://msdn.microsoft.com/library/de..._functions.asp
Especially the functions: RegOpenKey,RegSetValue,RegQueryValue (or the extented versions ...Ex) and RegCloseKey.

exman
 
  


Reply


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 do I write a script (batch file)?? cvzyl Linux - Software 4 07-30-2006 09:11 AM
Trigger linux command by windows batch file? mariusak Linux - Networking 6 06-03-2005 05:15 AM
call program on linux box from windows batch file naijaguy Programming 5 08-14-2004 11:12 AM
Linux box calling a batch script on a windows box to run? Is it possible? joelhop Programming 8 05-17-2004 04:49 PM
How to make our program run at booting ssatheesh Linux - Software 2 03-01-2003 10:41 AM


All times are GMT -5. The time now is 08:30 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration