Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is a drive?

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the knowledge of "what is a drive". In the operation of practical cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Driver programming is very important for hacker programming. Fortunately, vbs provides us with convenient collections, which makes the job very easy.

1. Check the drive

Using the driveexists method of filesystemobject

For example:

Set fs=createobject ("scripting.filesystemobject")

If fs.driveexists ("h") then

.

2. Get the drive properties

You can use the getdrive method, and then you can use the properties of the drive object or the drive of. Common properties are

Drivetype: returns drive type 0 as an integer for unknown 1 for removable 2 for fixed 3 for network drive 4 for cd-room

5 means ram disk

Freespace: free space

Totalsize: total space

Volumename: drive label 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 "free space" & y

* * *

If you remember, you should know that there is also a drives collection, which is more convenient than previously mentioned, for example, we can get this collection if we want to get all the drives on the system, and then use foreach to check. In addition, sometimes we have to program a virus, which may infect the floppy disk. At this time, we need to check whether the floppy disk is ready. Take a look at 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 set of drives

For each d in dc

N = ""

Swatches & d.driveletter & "- -"

If d.drivetype=remote then

N=d.sharename

Elseif d.isready then

N=d.volumename

End if

Scars & n & crlf

Next

Getdrivelist=s

End function

* * *

3. Map network drives

Network sharing must be mapped for script users to use. Mapping can be achieved using the mapnetworkdrive method of the network object.

Set wn=wscript.createobject ("wscript.network")

Wn.mapnetworkdrive "k:", "\\ yaya\ music", true

The last parameter specifies whether the mapping is permanent or not, and if the last parameter is not written, the mapping will be cancelled the next time it starts.

Use wn.removenetworkdrive "k:", true,true if you want to break the mapping

If the network drive is in use, to force disconnect, set the second parameter to true

This is the end of what is a drive. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report