super simple batch file, noob programming help needed

SarverSystems

Supreme [H]ardness
Joined
Feb 9, 2002
Messages
7,408
I am looking for a way to automatically rename a file between midnight and 8AM.

This is on a WinXP machine.

The batch file must be able to run unattended, and it cannot have any windows or other popups indicating it's presence while being run.

It also must name the file back to its original name NOT during the above hours.

This is for a system under my control. I am attempting to rename the hosts file to prevent unauthorized web access to certain sites during certain hours.
 
I am looking for a way to automatically rename a file between midnight and 8AM.

This is on a WinXP machine.

The batch file must be able to run unattended, and it cannot have any windows or other popups indicating it's presence while being run.

It also must name the file back to its original name NOT during the above hours.

This is for a system under my control. I am attempting to rename the hosts file to prevent unauthorized web access to certain sites during certain hours.

Parental Control?
 
That would be super simple. I can't test a batch file right now but you could just set up two scheduled tasks. One at 12am to rename the hosts file and another at 8am to rename it back. Quick and easy.

As a side note some routers can block certain IP's at certain times of the day. Just another option to look at.
 
Why don't you just keep a copy of a good hosts file elsewhere on the computer and use simple copy commands to overwrite the supposed bad file? You probably want to run a script since a bat file will show up on the taskbar when it runs.

Here's an example of a script to copy a file to another location and overwrite existing file.

Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Temp\*.bkf" , "E:\" , OverwriteExisting


Copy that text and paste into a text file and then give it a .vbs extention.
 
Will anti-virus software pick up that .vbs file as a virus? I know it isn't a virus, but you know how virus scanners are. Anything suspicious gets flagged.
 
NOD32 is ok with it. Should be ok.
Should also mention you just need to change the file name and locations in the quotation marks on the last line to fit your situation. That particular script copies all files with a .bkf extention from c:\temp to e:\
 
Back
Top