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

标签 windows visual-studio batch-file visual-studio-shell

我们如何通过批处理脚本检查是否安装了 Visual Studio Shell 以及安装了哪个版本?

我知道我们可以检查文件/文件夹是否存在

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

但我正在寻找更优雅、更通用的解决方案。

有什么帮助吗?

已接受答案的更新:

您的回答很优雅并且完成了任务。由于我专门检查某些版本,因此我正在使用(在检查您提供的链接之后):

@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

如果您需要更多详细信息,请访问 plenty of reg keys您可以查询以获取更多信息,但是从键和值中提取所需数据会更加困难。

注意:如果您在 x64 上运行,那么您可能需要添加对 %systemdrive%\Program Files (x86) 的检查取决于安装 VS 的位置。

关于windows - 从批处理中检查 Visual Studio Shell 安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13880742/

相关文章:

windows - 即使使用同一用户进行服务,也无法通过 Windows 服务访问 UNC 路径

c++ - 将字符转换为宽字符

php - 如何通过 php 读取 Windows unicode 文件并将它们存储在 utf-8 数据库中?

python - 提高套接字传输速度

c# - 使用对象发送者和 EventArgs 调用方法 c#

windows - 用于从网络驱动器中删除文件的批处理文件命令

windows - 如何在 Windows 上使用 git+mintty+mingw 获得彩色输出?

c# - 为什么 visual studio 2012 找不到我的测试?

c# - 使用 CSC 分别编译单个目录中的多个文件

windows - Batch/Powershell 多语言中的奇怪重定向