How do I programmatically change the label of a mapped drive?

后端 未结 2 2146
囚心锁ツ
囚心锁ツ 2021-02-19 16:45

I\'m writing a piece of software which maps a network drive using the WNetAddConnection2 API. Just in case it\'s relevant, this is a WebDAV drive, rather than a normal SMB shar

2条回答
  •  清歌不尽
    2021-02-19 16:59

    You could use PowerShell in your C# code, the https://msdn.microsoft.com/en-us/library/system.management.automation.powershell(v=vs.85).aspx

    Change DriveLetter E to Q with PowerShell

    $drive = Get-WmiObject -Class win32_volume -Filter "DriveLetter = 'e:'"
    Set-WmiInstance -input $drive -Arguments @{DriveLetter="Q:"; Label="Label"}
    

提交回复
热议问题