HoppaLong Posted March 17, 2010 Share Posted March 17, 2010 (edited) I haven't had to add lines to autoexec.bat for several years.I want to import or merge a couple of registry files before Windowsstarts. This must happen each time the system boots, not just once.Right now, my autoexec.bat file is empty.I tried this:CALL C:\myfile.regThe result was an "invalid switch" error.Someone mentioned on another forum that all you need isthe pathname to the reg file, nothing else.Rather than messing around with autoexec.bat, I would behappier if I could find a little applet that could do the job. I've searched, but I can't find anything.If it can be done easily using autoexec.bat, please, show methe way!One thing I do remember about these "run > sysedit" filesis how strange they can be. Command lines that work onone system may fail on another. That's why I was hoping to find a simple command line app. [[ You might remember the command line tool RegDel. I used it hundreds of times to delete keys and values. It never failed. Its still available here: http://www.softlookup.com/display.asp?id=9849 ]] Edited March 17, 2010 by HoppaLong Link to comment Share on other sites More sharing options...
rloew Posted March 18, 2010 Share Posted March 18, 2010 Try the following line in your AUTOEXEC.BAT file:REGEDIT C:\myfile.reg Link to comment Share on other sites More sharing options...
MDGx Posted March 18, 2010 Share Posted March 18, 2010 For 100% unattended ["hands free"] operation [no prompts, no pause], use the /S switch in autoexec.bat or batch file (example):REGEDIT /S C:\MYREG.REGMust specify full path to REG file [unless found in the PATH statement] and reg file extension.FYI:The CALL command works only with batch files [*.BAT].HTH Link to comment Share on other sites More sharing options...
HoppaLong Posted March 18, 2010 Author Share Posted March 18, 2010 I've created countless shortcuts and typed a zillion"run" commands with that REGEDIT /S. It always worksperfectly from within the Windows environment.I'm 99% certain I added the line "REGEDIT /S C:\MYREG.REG"to autoexec.bat. It returned an error message.I also created a batch file:@ECHO OFFREGEDIT /S C:\MYREG1.REGREGEDIT /S C:\MYREG2.REGI reviewed a couple of my old books about DOS.You're right about CALL, MDGx.I tried again:CALL C:\MYFILE.BATAn "Invalid Switch" error was returned.Years ago, I can't believe how patient I was with DOS.What choice did we have? There was no GUI. Thank goodness,many of the newer scripting languages are more reliable andpowerful.One of my DOS books goes into great detail about addinglines to config.sys and autoexec.bat. The author mentionsthat 99% of the time a new line should be added at thebottom of the file.He says to press Ctrl+End and then hit the Enter key.Since my autoexec.bat file is empty, there is no end orbeginning. Just to make sure the system recognizedthe file as empty, I used "select all > delete > save."The cursor does not move with the arrow keys, so thefile is definitely empty!If the command lines shown above are correct, why isDOS returning error messages?Here is a quote I saved from another forum:"I know other batch files can be run through a batchfile by using the "call" command, but this doesn'twork for registry files."I apologize guys. DOS always made me feel stupid!The "call" command must work for a batch file, butit's not working as the first line in my autoexec.batfile.REGEDIT /S [PATHNAME] added to my empty autoexec.batfile doesn't work either.You don't have to tell me that it must work. For somereason, DOS is kicking me in the a**, like it has somany times in the past. Link to comment Share on other sites More sharing options...
LoneCrusader Posted March 19, 2010 Share Posted March 19, 2010 The CALL command works only with batch files [*.BAT]. I used the CALL command to call WININIT.EXE in my FIX95CPU patch script. It works... Link to comment Share on other sites More sharing options...
dencorso Posted March 19, 2010 Share Posted March 19, 2010 Of course it does work with .EXEs and .COMs...I think MDGx meant to say "CALL only works from within batch files". And, in a sense, this is true...If you invoke a batch file directly from within a batch file, the second batch fails to return to the first one, as it ends, causing both to terminate, while if you invoke the second batch file by means of the CALL command, then the second batch, after it ends, returns to the first one, which resumes processing normally. This is the reason for which the CALL command was created, in the first place.On the other hand, invoking .EXEs and .COMs with CALL or without it have the exact same result. Link to comment Share on other sites More sharing options...
herbalist Posted March 19, 2010 Share Posted March 19, 2010 You need to exit the command prompt interpreter for the called batch file. Add this to the end of the called batch file:command /c exit Link to comment Share on other sites More sharing options...
herbalist Posted March 19, 2010 Share Posted March 19, 2010 The "/s" switch for regedit is invalid in autoexec.bat. You should be able to launch regedit directly from autoexec.bat.Try it using this syntax:REGEDIT C:\folder\MYREG1.REGREGEDIT C:\folder\MYREG2.REGIt would also be better if you have the .reg files in a folder instead of your root directory. I seem to remember that there's some limitation regarding the number of file entries in the root directory. Link to comment Share on other sites More sharing options...
HoppaLong Posted March 19, 2010 Author Share Posted March 19, 2010 OK herbalist.As I quickly discovered, adding the /S switch to autoexec.batbrings up an "invalid switch" error.Here's another "believe it or not" sort of thing. I dohave my reg file in a root folder, like you show in yourreply:REGEDIT C:\folder\MYREG1.REGHowever, if I include "C:\" in the command I get an errormessage! If I leave it out, the files are imported normally.The folder name is MERGREG, so it shouldn't cause anyproblems. There are no spaces and it stays within theeight letter naming convention.I don't expect a logical explanation, but why do the commandswork only when the "C:\" is not included:Like this:REGEDIT MERGREG\MYFILE.REG Link to comment Share on other sites More sharing options...
dencorso Posted March 19, 2010 Share Posted March 19, 2010 You need to exit the command prompt interpreter for the called batch file. Add this to the end of the called batch file:command /c exitI respectfully disagree. More info here: CALL. Link to comment Share on other sites More sharing options...
herbalist Posted March 20, 2010 Share Posted March 20, 2010 You need to exit the command prompt interpreter for the called batch file. Add this to the end of the called batch file:command /c exitI respectfully disagree. More info here: CALL.On my present 98SE unit, adding "command /c exit" to the called batch file did prevent the system from booting. On my 98FE unit, I call a batch file from autoexec.bat that's very similar to the one in my signature. That batch file ends with "command /c exit" and the system will not finish booting if I remove it. I can't explain this discrepancy unless FE and SE behave that much differently, or something else I did on that system is changing that behavior. Right now, the monitor for my FE unit failed so I can't compare them. I did make a VPC copy of that FE system, allowing it to change drivers as necessary, hoping to test this on it. Batch files don't run properly on VPC. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now