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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BAT Files

Status
Not open for further replies.

gust1480

Programmer
Mar 19, 2002
148
PH
I'm trying to make a program that will protect my bat files from being opened by anybody. is it possible? what functions should I use?
 
Since batch files are normally in plain text I'm not sure that VB will be much help. Permissions on text files are normally an OS thing. But this will bump you up- maybe someone else knows of something that I don't.
 
Excellent. The you can hide the contents of your batch files in an NTFS stream. I'm not in front of NT box at the moment, so you'll have to wait a few hours before I can give you some illustrative code.

Off the top of my head, something like the following:
[tt]
Private Sub Command1_Click()
Dim hFile As Long

hFile = FreeFile

Open "c:\mytest.bat:datastream" For Output As hFile
Print #hFile, "dir"

Close hFile
Shell "c:\mytest.bat:datastream"
End Sub

Now, if another user does a Dir, looking for your batch file, all they will find is c:\mytest.bat. If they try and cat it, or edit it, or run it they won't get anything. They need to know the name of the stream before they can access it.
 
One thing about streams to consider, the batch file strongm mentioned will be 0 bytes long. if someone deletes it, your stream, and therefore your batch file will be gone.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top