如何使用FileSystemObject删除Windows Junction?

时间:2014-12-20 01:09:29

标签: windows filesystemobject vhd wsh mount-point

我使用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
  }

我错过了什么吗?

P.S。

我通过这样做解决了这个问题:

 var shell = WScript.CreateObject("WScript.Shell");
 shell.Run("cmd /c rmdir " + vhdmountpoint);

我认为这算作黑客攻击。

0 个答案:

没有答案