改变letra da unidade(笔式驱动器) [英] Change letra da unidade (pen drive)

查看:91
本文介绍了改变letra da unidade(笔式驱动器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家下午好。

我是新来的,我很乐意帮助你。

我想知道是否可以改变或在驱动器中写一封信。

示例:我有一个名为test的USB记忆棒和字母,由系统自动分配。

我想通过名称:测试VolumeName并为驱动器添加一个特定的字母driveletter:P

如果系统没有为该单元分配一个字母,则将字母P。

因此,每当我运行它时,将识别名称为test的卷,并为该卷指定字母p。

提前感谢您。

Visual Basic 2010



我尝试过:



Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles MyBase.Load

Dim fso As New Scripting.FileSystemObject()

Dim drv As Scripting.Drive

Dim string_bui lder As New System.Text.StringBuilder()

Dim asd As String

Dim letra As String



每个drv In fso.Drives

string_builder.Append(_

drv.DriveLetter& :& vbCrLf& _

类型:& drv.DriveType.ToString()& vbCrLf)

如果是drv.IsReady那么

string_builder.Append(_

文件系统:& drv.FileSystem& vbCrLf& ; _

自由空间:& drv.FreeSpace& vbCrLf& _

总大小:& drv.TotalSize& vbCrLf& _

卷名:& drv.VolumeName& vbCrLf& _

序列号:& drv.SerialNumber& vbCrLf& _

--------------------& vbCrLf)

asd = drv.VolumeName

letra = drv.DriveLetter

如果asd =ws那么

MsgBox(drv.VolumeName)

drv.DriveLetter = p









否则

MsgBox(nao)

结束如果

Else

string_builder.Append(_

未准备好 &安培; vbCrLf& _

--------------------& vbCrLf)

结束如果



下一个drv





txtDrives.Text = string_builder.ToString()

txtDrives.Select(0,0)



End Sub



Private Sub txtDrives_TextChanged(ByVal sender As System.Object,ByVal e As System.EventArgs)处理txtDrives.TextChanged



End Sub

结束类

Good afternoon everyone.
I'm new here, I'd love your help.
I wonder if and can change or put a letter in the drive.
Example: I have a USB stick with the name "test" and the letter and assigned automatically by the system right.
I would like to identify the stick through the "Name: test" "VolumeName" and put a specific letter for the drive "driveletter: P"
if the system has not assigned one letter to the unit, put the letter "P".
So whenever I run it would identify the volume with the name "test" and is assigned the letter "p" for the volume.
Thank you in advance.
Visual Basic 2010

What I have tried:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim fso As New Scripting.FileSystemObject()
Dim drv As Scripting.Drive
Dim string_builder As New System.Text.StringBuilder()
Dim asd As String
Dim letra As String

For Each drv In fso.Drives
string_builder.Append( _
drv.DriveLetter & ":" & vbCrLf & _
" Type: " & drv.DriveType.ToString() & vbCrLf)
If drv.IsReady Then
string_builder.Append( _
" File System: " & drv.FileSystem & vbCrLf & _
" Free Space: " & drv.FreeSpace & vbCrLf & _
" Total Size: " & drv.TotalSize & vbCrLf & _
" Volume Name: " & drv.VolumeName & vbCrLf & _
" Serial Number: " & drv.SerialNumber & vbCrLf & _
"--------------------" & vbCrLf)
asd = drv.VolumeName
letra = drv.DriveLetter
If asd = "ws" Then
MsgBox(drv.VolumeName)
drv.DriveLetter = "p"




Else
MsgBox("nao")
End If
Else
string_builder.Append( _
" Not ready" & vbCrLf & _
"--------------------" & vbCrLf)
End If

Next drv


txtDrives.Text = string_builder.ToString()
txtDrives.Select(0, 0)

End Sub

Private Sub txtDrives_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDrives.TextChanged

End Sub
End Class

推荐答案

识别拇指驱动器的方法之一是使用WMI。



您可以查看我的PowerShell脚本并将其用作伪代码:
One of the ways to identify the thumb drive is using WMI.

You can look at my PowerShell scrip and use it as a pseudo-code:


removable = Get-WmiObject CIM_StorageVolume
removable = Get-WmiObject CIM_StorageVolume


r |其中{


这篇关于改变letra da unidade(笔式驱动器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆