# Usefull Batch Files



## tommo020788 (Oct 20, 2008)

Hi, I'd like to get a list of useful batch files, and put them all into a collection.

I have a few different useful batch codes I have made in the past, so I will post them here to start the list 

Please post any useful batch codes you have come across.

Usefull Batch Codes:

*Give permissions for file:*
*Description: *This allows you to give full read/write permissions for a file to a specified user.

```
echo off
cls
set /p UN=Please Type Your Username(including upper case letters)or type "Everyone" to give permissions to everyone:
echo Permissions will be given to %UN%
pause...
set /p pth=Please drag and drop the file into this window, then hit enter to continue:
cacls %pth% /E %UN%:f
```
*Network Messenger:*
*Description:* This allows users within a local network to send messages to each other, easily and conveniently(note: The "Net messenger" service must be enabled to use this).

```
color 0f
@echo off
cls
net start messenger
cls
:A
echo messenger
set /p n=user/ip:
set /p m=message:
net send %n% %m%
pause
goto A
```
*File Scanner/Killer:*
*Description:* This is usefull for when you have duplicates of a file throughout your hard drive. I have also used it to kill off a virus that copied itself to various folders on my hard drive.
The program will find all files with the name you specify, from each sub-directory, and delete them.

```
TITLE "File-Scan-Kill"
Echo: "This will delete all files with the name you specify, from all subdirectories. Run this program from the C: root directory for best results." 
set /p FN= Type the name of the file, including the file extention (example~ file.exe):
>>log.txt DEL /s /F \%FN%
```
*Admin Pass Reset:*
*Description:* This program will allow you to change the main "Admin" password if you forgot what it is. (note: you need an administrator account to be able to use this)


```
[COLOR=RoyalBlue][COLOR=black]echo off[/COLOR]
[/COLOR]TITLE "Admin Pass Changer"
cls
echo "Hit Enter to change Admin Password"
pause...

cls
echo "choose a password"
net user "Administrator" *

TITLE "Administrator password changed"
cls

echo "#########################################################
echo " P______________________________________\ 
echo " |MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMD | 
echo " |MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMD | 
echo "  |WWWWWWWWWW.........................D | 
echo "  |WWWWWWWWWW___________________________/ 
echo "  |MMMMMMMMV0                             
echo "  |MMMMMMM|     YOUR DONE!           
echo "  |MMMMMMM|     now go to user login, type administrator                         
echo "  |MMMMMMM|     then use the password you typed                          
echo "  |MMMMMMM|                               
echo "  BBBBBBBBB     programmed by Tom |virus hackers| ;)                          
echo "#########################################################

pause...
```


*File Hider:*
*Description:* This program will allow you to hide a file or folder that you specify. It will then save the directory/file name that you choose, to a txt file to be read later by the "unlocker" batch file, that will make the file visible again.
The program changes the actual attribute of the directory you specify, instead of just setting it to "hidden" it makes the specified directory virtually Inaccessible!
*There are two codes here... use the "File Hider" code to hide a file, then use the "File Unlocker" code to make the file visible again.*

*File Hider*

```
echo off
Set /p PTH= Please drag and drop the file or folder into this window, then hit enter:
echo %PTH% >txt.txt
set /p var= <txt.txt
echo %var% has been selected to be hidden. Hit enter to coninue.
Pause...
attrib %PTH% +s +h
```
*File Unlocker
*

```
echo off
set /p var= <txt.txt
echo %var% is set to hidden. Hit enter to make it visable again.
Pause...
attrib %var% -s -h
```


----------



## Squashman (Apr 4, 2003)

NET SEND is obsolete. Cannot be used on Vista or 7.

I guess I don't see the point of writing an entire batch file that could be done with one line of code at the cmd prompt.


----------



## tommo020788 (Oct 20, 2008)

oh true... I didn't realize it was taken off for vista and 7 :/ is there another similar service used on vista and 7?


----------



## Squashman (Apr 4, 2003)

msg.exe


----------



## tommo020788 (Oct 20, 2008)

Thanks for the help Squashman.
Any suggestions for useful batch files to add to the list?


----------



## Squashman (Apr 4, 2003)

Not really. 

My idea of a useful batch file is something that is specific to my needs. Most of the batch files I write are specific to a very localized task that most people will never encounter. I am sure if you searched the DOS category you will find plenty of Batch files.


----------



## TheOutcaste (Aug 8, 2007)

Are you aware that your *Give permissions for file* batch file could make your system unbootable if you pick the wrong system file? That's because it doesn't just add that user, it removes all other users, _including_ the system account, which will deny access by those accounts.
Do that with Explorer.exe, and the account you name will be the only one that can run explorer, meaning no other account will have a taskbar, start menu, or desktop icons.

It also changes every file with a matching name in the tree, so if you drop *C:\Windows\explorer.exe*, not only does that file get changed, but so do these:
*C:\Windows\$NTServicePackUninstall$\explorer.exe
C:\Windows\ServicePackFiles\i386\explorer.exe*
Plus any other copies from other Windows Updates.

Don't use the */T* to prevent changing files other than the one dropped, and use */E* instead of */G* unless you really want to deny all other accounts access to the file.


----------



## tommo020788 (Oct 20, 2008)

hey thanks for that advice outcastle. I will change those options around.
EDIT:
ok well I would change it if I could... but for some strange reason, I can't see an "edit" tab on my first post anymore...


----------



## TheOutcaste (Aug 8, 2007)

The forum only allows you to edit for 24 hours. After that you need a Mod or Admin to edit things.


----------



## tommo020788 (Oct 20, 2008)

Ah I c, I will request a moderator to change it then, just in case someone does do some damage to their computer with that particular batch file like you said.


----------



## valis (Sep 24, 2004)

outcaste, can you specify the changes that need to be made?

thanks, 

v


----------



## Cookiegal (Aug 27, 2003)

tommo020788 asked me to edit it but I'm unclear how it should read. Please post the new batch in code tags and I will make the edit. For now, I will delete the batch.


----------



## tommo020788 (Oct 20, 2008)

The batch should be changed to look like this:


```
echo off
cls
set /p UN=Please Type Your Username(including upper case letters)or type "Everyone" to give permissions to everyone:
echo Permissions will be given to %UN%
pause...
set /p pth=Please drag and drop the file into this window, then hit enter to continue:
cacls %pth% /E %UN%:f
```


----------



## Cookiegal (Aug 27, 2003)

Thanks. I've inserted the revised batch in the initial post.


----------



## tommo020788 (Oct 20, 2008)

cheers cookiegal


----------



## Cookiegal (Aug 27, 2003)

tommo020788 said:


> cheers cookiegal


:up:


----------

