Driver Programming is crucial for hacker programming. Fortunately, vbs provides us with a convenient set, making our work very simple.
1. Check the drive
Use the driveexists method of filesystemobject
For example:
Set fs = createobject ("scripting. filesystemobject ")
If fs. driveexists ("h") then
......
2. Get Drive attributes
You can use the getdrive method, and then use the drive object attributes or drive attributes. Common attributes are:
Drivetype: return the drive type in integer form. 0 indicates unknown 1 indicates movable 2 indicates fixed 3 indicates network drive 4 indicates cd-room
5 indicates the ramdisk
Freespace: available space
Totalsize: Total Space
Volumename: Drive Volume
For example:
**************************************** ****************
Set fs = createobject ("scripting. filesystemobject ")
Set drv = fs. getdrive ("D ")
T = drv. drivetype
Y = drv. freespace
Wscript. echo "type" & t
Wscript. echo "available space" & y
**************************************** ***************
If you still remember, you should know that there is another drives set, which is more convenient than we mentioned earlier. For example, we need to get the set from all the drives on the system, then use foreach to check. In addition, sometimes we need to prepare a virus that may infect a floppy disk. In this case, we need to check whether the floppy disk is ready. Check the following program:
**************************************** ******************
Wscript. echo getdrivelist ()
Function getdrivelist () 'custom function
Dim fs, d, dc, s, n, crlf
Crlf = chr (13) & chr (10)
Set fs = createobject ("scripting. filesystemobject ")
Set dc = fs. drives get the drive set
For each d in dc
N = ""
S = s & d. driveletter &"--"
If d. drivetype = remote then
N = d. sharename
Elseif d. isready then
N = d. volumename
End if
S = s & n & crlf
Next
Getdrivelist = s
End function
**************************************** *******************
3. MAP network drives
Network Sharing is only available for script users after ing. The mapnetworkdrive method of the network object can be used for ing.
Set wn = wscript. createobject ("wscript. network ")
Wn. mapnetworkdrive "k:", "\ yaya \ music", true
The last parameter specifies whether the ing is permanent. If the last parameter is not specified, the ing will be canceled at the next startup.
If you want to disconnect the ing, use wn. removenetworkdrive "k:", true, true
If the network drive is in use, set the second parameter to true to force disconnection.
The third parameter indicates that the ing is permanently canceled.