Reply to thread

No way to force to use fixed letter drive, i succeed to make it work from powershell but don't succeed to port to C# lol.

So i have let the selection to MP config for now and back the old way and it seems but i need to test more than using that code :


[CODE=C#]        using (var ps = PowerShell.Create())

        {

          // Set mounted ISO file to be able to unmount it if something failed to load.

          _MountedIsoFile = IsoFile;

          Log.Debug("Mount-DiskImage {0}", IsoFile);

          ps.AddCommand("Mount-DiskImage").AddParameter("ImagePath", IsoFile).AddParameter("PassThru");

          Log.Debug("Mount-DiskImage Result {0}", psResult.Count);

        }


        using (var ps = PowerShell.Create())

        {

          ps.AddCommand("Get-DiskImage").AddParameter("ImagePath", IsoFile).AddCommand("Get-Volume");

          var psResult = ps.Invoke();

          Log.Debug("Mount-DiskImage Result {0}", psResult.Count);

          foreach (var driveLetter in psResult.Select(result => result.Members["DriveLetter"].Value.ToString()))

          {

            _Drive = String.Format("{0}:", driveLetter);

            Log.Debug("Mount-DiskImage DriveLetter {0}", _Drive);

          }

        }[/CODE]


The newest letter drive is always get (result.count = 1).

But i fear it's timing issue and then it will failed one day to another or one minute to another lol

Attached is the modified file.


The first i mount the iso and the second i ask from driveletter, when i use all ps.command in one, sometimes (most of the time), i didn't get result but doing that twice ps.addcommand and it seems to work better.


Otherwise the powershell command used to change drive letter :


$drive = Get-WmiObject -Class win32_volume -Filter "DriveLetter = 'e:'"

Set-WmiInstance -input $drive -Arguments @{DriveLetter="O:"; Label="Label"}


We really need to have this syntax : -Filter "DriveLetter = 'e:'" -> 'e:' is the current mounted drive

And i change it to O: by -Arguments @{DriveLetter="O:"; Label="Label"}


:p


Edit : re-uploaded the zip.


Top Bottom