After reading this Article:
"Create Fake Dummy File on USB Flash Drive to Enable Write Protect and Prevent Modification" I have this idea to create a good Trick in Vbscript.
So i explain what this script can do:
You carry your USB flash drive that contains a lot of portable tools with you all the time but you are afraid of one thing, which is a computer virus such as JambanMu or MaxTrox or Sality that are able to infect USB flash drives and bind themself to the executable files in there. So far there are only ways to disable writing to USB flash drive on your computer by editing the registry but if you plug it into a public computer which has virus, your USB flash drive will be writable and can be infected by virus. So is having a pendrive with a built-in write protect switch the only way to prevent the drive from virus infection?
The Script creates a “block” file to fill up the remaining free space on the USB flash drive. When there is no space left on the removable drive, virus won’t be able to copy itself to to drive or infect any executable files.
This Code is used to create a fake Dummy file on USB Flash Drive to Enable Write Protect and Prevent Modification
'----------------DummyFileCreator.vbs---------------
'© Hackoo ©
'web site http://hackoo.ifrance.com
Dim WshShell,FSO,Drv,Dtype,Dfree,DfreeMB,Dtot
Dim Dname,Dpct,Dused,Dserial,Dinfo
Set WshShell=WScript.CreateObject("WScript.Shell")
Set FSO=CreateObject("Scripting.FileSystemObject")
For each Drv in FSO.Drives
If Drv.DriveType=0 Then Dtype="Unknown "
If Drv.DriveType=1 Then Dtype="Removable"
If Drv.DriveType=2 Then Dtype="Fixed "
If Drv.DriveType=3 Then Dtype="Network "
If Drv.DriveType=4 Then Dtype="CD-ROM "
If Drv.DriveType=5 Then Dtype="RAM Disk "
If Drv.IsReady Then
If Drv.DriveType=1 Then
Dfree=Drv.FreeSpace
DfreeMB=FormatNumber(Drv.FreeSpace/(1024^2),0)&" MB"
Label=Drv.DriveLetter
end if
end if
Next
MsgBox "Espace Libre dans Le Flash Disk "&Label&":\"&" est Environ de " &DfreeMB,64,"Espace Libre"
WshShell.run "cmd /c fsutil file createnew "&Label&":\IamDummy " &Dfree&"",0,True
WshShell.Run "cmd /C attrib +h +s "&Label&":\IamDummy",0,TRUE
And This Code is used to delete The Fake Dummy File and so let you write into your pendrive
'----------------NoDummyFile.vbs---------------
'© Hackoo ©
'web site http://hackoo.ifrance.com
Dim WshShell,FSO,Drv,Dtype,Dfree,DfreeMB,Dtot
Dim Dname,Dpct,Dused,Dserial,Dinfo,filespec
Set WshShell=WScript.CreateObject("WScript.Shell")
Set FSO=CreateObject("Scripting.FileSystemObject")
filespec="IamDummy"
For each Drv in FSO.Drives
If Drv.DriveType=0 Then Dtype="Unknown "
If Drv.DriveType=1 Then Dtype="Removable"
If Drv.DriveType=2 Then Dtype="Fixed "
If Drv.DriveType=3 Then Dtype="Network "
If Drv.DriveType=4 Then Dtype="CD-ROM "
If Drv.DriveType=5 Then Dtype="RAM Disk "
If Drv.IsReady Then
If Drv.DriveType=1 Then
Dfree=Drv.FreeSpace
DfreeMB=FormatNumber(Drv.FreeSpace/(1024^2),0)&" MB"
Label=Drv.DriveLetter
end if
end if
Next
If (fso.FileExists(Label&":\IamDummy")) Then
Set MyFile = fso.GetFile(Label&":\IamDummy")
MyFile.Delete
End If
MsgBox "Espace Libre dans Le Flash Disk "&Label&":\"&" est Environ de " &DfreeMB,64,"Espace Libre"