Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch file help - need to create text file. 1

Status
Not open for further replies.

hotfusion

Technical User
Jan 20, 2001
755
GB
I've searched around, but haven't found what I'm looking for, so now over to the brains on here.

I'm using a junk-clearing batch file on a number of WIN98 machines, and one of the (optional) menial tasks is to clear out the autocomplete data from the registry. I currently do this by using a separate regedit 4 file along with the batch file, and invoke it using the following line:

REGEDIT %WINBOOTDIR%\URL.REG

This works fine, but it would be simpler if there was some way of creating the regedit file directly from within the batch file, use it, then delete the file once used, so that there was only the one file for people to 'install', rather than two, which seems to be causing some confusion. The .reg file would need to contain the following text:

REGEDIT4
[-HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\TypedURLs]

Can anyone give me some tips as to how I can create this file with this specific content? My understanding of anything more than the most basic commands is severely limited, so some pointers would be of enormous help and greatly appreciated.

Thanks.

Regards, Andy.
**************************************
My pathetic attempts at learning HTML can be laughed at here:
My home page
 
Its very simple really using the echo command.

Code:
@ECHO OFF

echo REGEDIT4 [-HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\TypedURLs] > url.reg

start .REGEDIT %WINBOOTDIR%\URL.REG

del url.reg

Make sure the contents of the regedit file is on a single line no breaks or anything. then just direct the echo to the file name using the ">" character.

Run the reg file, i used "start" to make sure the bat file waits for the reg file to finish before trying to delete it.


----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Forget "start" better use the "Pause" command before deleting the file.
Pause generates the message "Press any key to continue" and waits for a keystroke before moving on and deleting the file.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thanks very much for the info - I've tried what you suggest and it does indeed create the file I need.

(Incidentally, I've decided not to delete the file afterwards - it does no harm to leave it until it's needed next time, and saves complication.)

One problem I've noticed is that the regedit file doesn't actually work as is, but with a bit of tweaking of the code you gave me I've managed to get it to work, so will detail it here for the benefit of anybody else. There were two issues with the regedit file I identified, but I'm unsure which was the culprit:

One was the trailing space after the regedit information, cured by moving the '>' back one space;

The other was the 'REGEDIT4' being on the same line as the instruction. Again, I'm unsure whether this matters, but every other regedit file I've encountered has this on a separate line. I managed to force the file to output on two lines by doing as you suggested for just the 'REGEDIT4' part, and then appending the rest to the new file by using the '>>' instruction. (I was able to look this up once you'd pointed me to the 'echo' command! I had no idea where to start looking before!)

All seems to work now, so a star for you.
Thanks very much for your prompt and concise reply

Regards, Andy.
**************************************
My pathetic attempts at learning HTML can be laughed at here:
My home page
 
You're very welcome. I'm glad I could help.
I must say I admire your tenacity to actually research the >> appending character instead of asking here. most forum users would not have bothered. kudos for you.


----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top