我正在使用 diskpart 将 VHD 安装到文件夹(连接)。
卸载 VHD 后,我需要使用 FileSystemObject 删除该文件夹。
var vhdPath = "D:\SomeVhd.vhd";
var fsObj = new ActiveXObject("Scripting.FileSystemObject");
var TypeLib = WScript.CreateObject("Scriptlet.TypeLib");
var vhdmountpoint = fsObj.GetDriveName(vhdPath) + "\\" + TypeLib.Guid;
//Mount with diskpart here, vhdmountpoint is now a junction
//Dismount with diskpart here, vhdmountpoint still a junction
if (fsObj.FolderExists(vhdmountpoint)) { //returns true!
fsObj.DeleteFolder(vhdmountpoint); //Returns path not found
}
我错过了什么吗?
附言
我通过以下方式解决了这个问题:
var shell = WScript.CreateObject("WScript.Shell");
shell.Run("cmd /c rmdir " + vhdmountpoint);
我想这算作黑客攻击。