Programmatically finding the VS2017 installation directory

前端 未结 10 1203
梦谈多话
梦谈多话 2020-12-06 17:49

With previous versions of VS you could query the registry to determine the installation directory for VS:

HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Visu

10条回答
  •  时光取名叫无心
    2020-12-06 18:42

    I use powershell like KindDragon suggested

    $Is64bitOs = $env:PROCESSOR_ARCHITEW6432 -eq 'AMD64';
    if ($Is64bitOs){
        $registryPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0";
    }
    else {
        $registryPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\14.0";
    }
    
    $VSInstallDir = (Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0 -Name ShellFolder).ShellFolder;
    

提交回复
热议问题