I have a Windows VM on Azure. On startup it runs powershell script:
Start-Process cmd.exe -ArgumentList "/c whoami.exe 1> c:whoami.log 2>&1" -wait
$tempPath = "$env:TEMP"
$exePath = "$tempPathvs_buildtools.exe"
Invoke-WebRequest -Uri https://aka.ms/vs/17/release/vs_BuildTools.exe -UseBasicParsing -OutFile $exePath
Start-Process cmd.exe -ArgumentList "/c $exePath --quiet --add Microsoft.VisualStudio.Component.TestTools.BuildTools 1> c:vs_buildtools.log 2>&1" -Wait
After creating the VM:
- whoami.exe works fine and writes nt authoritysystem to c:whoami.log file.
- vs_buildtools.exe is downloaded to C:WindowsTemp
- BuildTools doesn’t install anything. There is no dd_* log files in temp folder.
- c:vs_buildtools.log contains this error message:
The application cannot find one of its required files, possibly because it was unable to create it in the folder. Please make sure that the folder in which this application was downloaded is accessible and not read-only.
When I run the script via RDP it works fine and writes dd_* log files to temp folder.
Aslo I tried -Verb runAs. Same issue.
2
Answers
It is my fault I didn't show the whole script. I was sure that different parts of my script did not affect each other. But I was wrong. There was a piece of script which broke system paths including temp path:
This may be because the files got corrupted or not downloaded/ installed all the required files properly.
I have tried with your script and it is working fine in my VM:
Try with below script given by Guerlando OCs and check if it helps you to achieve your requirement.
dd_*
files along with vs and vs_buildtools setup files.:Installation:
Created sample project: