Go Back   Computer Forums > General Computing > Programming
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 06-29-2005, 02:50 PM   #1
Beta Member
Join Date: Apr 2005
Posts: 3
Default Batch File creation - Help Needed.


Ive created a cd that autoruns a graphical menu with clickable links, and one of the links points to a HOSTS.bat file that copies over a custom HOSTS file from the cd to the ..\drivers\etc folder on the system root.

The problem I'm having is that I'm unsure of the correct syntax to use to automatically overwrite the existing HOSTS file.

I need to write it to work on both Win2K and XP machines, so have included two lines; one copies the HOSTS file to WINDOWS\system32\drivers\etc, and one copies it to Winnt..\etc. Thsi seems to work ok, for if it's an XP machine it ignores the Winnt instruction and vica versa.

However, this has all been tested with my original HOSTS file temporarily renamed to HOSTS2, so there is no HOSTS file to be overwritten. I cannot seem to make it work if there is a HOST file already present.

Is there a switch to make it overwrite? Or changing tack entirely, is there a way I can instruct the IP address I need to be written into the original HOSTS file?

Here is the contents of the batch file as it stands:


copy "hosts" "C:\WINDOWS\system32\drivers\etc\hosts"

copy "hosts" "C:\WINNT\system32\drivers\etc\hosts"

If anyone can help I would be most appreciative!

TIA ;-)
Bladerunner is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 05:00 PM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0