wmi接口如何通过Win32_Volume类修改盘符
2017年6月18日 10:06
想要通过wmi接口修改windows盘符,该如何实现呢?wmi提供了Win32_Volume类,通过该类可以修改盘符。
- python脚本
1 2 3 4 5 6 | import wmi_root_conn = wmi.WMI(privileges=["Shutdown"])query_str = "select * from Win32_Volume where DeviceID like '%%%s%%'" % volume_idvolume = _root_conn.query(query_str)[0]volume.DriveLetter = "M:"volume.put() |
- powershell脚本
1 2 3 | $Drive = Get-WmiObject win32_volume -Filter "Label = 'xxxx'"$Drive.DriveLetter = "m:"$Drive.put() |