Friday, August 19, 2022

Fix for "The system cannot open the device or file specified" error in Windows Installer

Some time ago I wrote instructions how to increase space on C drive by moving Windows Installer folder C:\Windows\SoftwareDistribution to D drive and creating junction link (see How to free space on OS Windows drive by moving SoftwareDistribution folder to another disk via junction folder). It works but there may be side effects: one of known issue is that after that some (not all) installations from msi files won't work. E.g. I faced with the following error when tried to installed NodeJS:

The system cannot open the device or file specified

 


One solution which you may try is the following:

  1. Remove junction link for C:\Windows\SoftwareDistribution folder (but keep actual folder which contains files on D drive!) and create normal folder C:\Windows\SoftwareDistribution (it will be empty)
  2. Run installer - it should work without errors and should put sub folders of new installation into C:\Windows\SoftwareDistribution
  3. After installation move sub folders from C:\Windows\SoftwareDistribution to SoftwareDistribution on D drive
  4. Delete C:\Windows\SoftwareDistribution folder
  5. Create junction link again

However there is simpler way to avoid mentioned error: run installer in silent mode from PowerShell. I found useful script which does it here. Will post it here in case link won't be available:

$fileName = "..."

$DataStamp = get-date -Format yyyyMMddTHHmmss
$logFile = '{0}-{1}.log' -f $fileName,$DataStamp
$MSIArguments = @(
    "/i"
    ('"{0}"' -f $fileName)
    "/qn"
    "/norestart"
    "/L*v"
    $logFile
)
Start-Process "msiexec.exe" -ArgumentList $MSIArguments -Wait -NoNewWindow 

Before to run it put full path to your msi file into $fileName variable. Script will run installer in silent mode and will write all steps into log file so you may check results. After that program should appear in the list of installed apps in Control panel > Programs and features.

No comments:

Post a Comment