简体   繁体   English

从批处理中检查Visual Studio Shell安装

[英]Check Visual Studio Shell Installation from Batch

How can we check if and which version of Visual Studio Shell is installed, from a batch script? 我们如何从批处理脚本检查是否安装了Visual Studio Shell以及安装了哪个版本?

I understand we can check the existence of file/folder say under 我了解我们可以检查下文件/文件夹是否存在

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE

But I am looking for a more elegant and generic solution. 但我正在寻找一种更优雅,更通用的解决方案。

Any help? 有什么帮助吗?

Update to accepted answer: 更新为接受的答案:

Your answer is elegant and does the task. 您的答案很优雅,可以完成任务。 Since I was specifically checking for certain versions, I am using (after checking the link you provided): 由于我专门检查某些版本,因此我正在使用(在检查了您提供的链接之后):

@echo off
reg query "HKEY_CLASSES_ROOT\VisualStudio.DTE.10.0" >> nul 2>&1
if %ERRORLEVEL% NEQ 0 ( echo VS 2010 not installed ) else ( echo VS 2010 installed. )
reg query "HKEY_CLASSES_ROOT\VisualStudio.DTE.11.0" >> nul 2>&1
if %ERRORLEVEL% NEQ 0 ( echo VS 2012 not installed ) else ( echo VS 2012 installed. ) 
@echo off
for /d %%a in ("%programfiles%\Microsoft Visual Studio*") do (
for /f "tokens=3 delims=\" %%x in ("%%a") do echo %%x
)
pause >nul

If you need more details there are plenty of reg keys you can query to get more info but that would be much harder to extract the data you wanted from the keys and values. 如果您需要更多详细信息,可以查询很多注册键以获取更多信息,但是要从键和值中提取所需的数据将更加困难。

Note: If you are running on x64 then you may need to add a check for %systemdrive%\\Program Files (x86) depending on where VS is installed. 注意:如果在x64上运行,则可能需要检查%systemdrive%\\Program Files (x86)具体取决于VS的安装位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM