zoukankan      html  css  js  c++  java
  • 获取VisualStudio命令行脚本路径(VS2019、VS2017、VS2015)

    GetVisualStudioEnvScript.bat

    @echo off
    setlocal enabledelayedexpansion
    
    call :GetVisualStudioEnvScript devenv
    echo devenv="!devenv!"
    
    if "%1" == "" (
        pause
    )
    exit /b 0
    
    ::获取字符串长度
    ::%1 string
    ::%2 len
    :StrLen
        setlocal enabledelayedexpansion
        set len=0
        set str=%~1
    
    :StrLenLoop 
        if not "!str:~%len%!"=="" (
            set /A len+=1
            goto :StrLenLoop
        )
        (endlocal & set %2=%len%)
        goto :eof
    
    ::查找字符串
    ::%1 string
    ::%2 token
    ::%3 pos
    :StrFind
        setlocal enabledelayedexpansion
        set "pos=0"
        call :Strlen %2 len
        set "str=%~1"
        set "token=%~2"
        ::echo str=%str% token=%token%
    :StrFindLoop
        if "!str:~%pos%,%len%!"=="" (
            (endlocal & set %3=-1)
            goto :eof
        ) else if not "!str:~%pos%,%len%!"=="!token!" (
            set /A pos+=1
            goto :StrFindLoop
        )
    
        if "!str:~%pos%,%len%!"=="!token!" (
            (endlocal & set %3=%pos%)
        ) else (
            (endlocal & set %3=-1)
        )
    goto :eof
    
    ::获取VisualStudio脚本
    ::%1 devenv
    :GetVisualStudioEnvScript
        setlocal enabledelayedexpansion
        for /f "Delims=" %%i in ('REG QUERY "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionApp Pathsdevenv.exe"') do (
            set "value=%%i"
            set "value=!value:*reg_sz=!"
            for /f "tokens=*" %%b in ("!value!") do set devenv=%%~fb
        )
    
        ::echo devenv="%devenv%"
    
        call :StrFind "%devenv%" "Common7IDEdevenv.exe" dirpos
        if %dirpos% == -1 (
            echo Visual Studio Version Unknown : "%devenv%"
            set "devenv="
            goto GetVisualStudioEnvScriptEnd
        )
    
        call :StrFind "%devenv%" "2019" pos
        if not %pos% == -1 (
            set "devenv=!devenv:~0,%dirpos%!VCAuxiliaryBuildvcvarsall.bat"
            goto GetVisualStudioEnvScriptEnd
        )
    
        call :StrFind "%devenv%" "2017" pos
        if not %pos% == -1 (
            set "devenv=!devenv:~0,%dirpos%!VCAuxiliaryBuildvcvarsall.bat"
            goto GetVisualStudioEnvScriptEnd
        )
    
        call :StrFind "%devenv%" "Microsoft Visual Studio 14.0" pos
        if not %pos% == -1 (
            set "devenv=!devenv:~0,%dirpos%!VCvcvarsall.bat""
            goto GetVisualStudioEnvScriptEnd
        )
        set "devenv="
    :GetVisualStudioEnvScriptEnd
        ::echo devenv="!devenv!"
        (endlocal & set "%1=%devenv%")
    goto :eof

    输出:

  • 相关阅读:
    我要自学网asp.net学习第一天(课程概述)
    在eclipse中创建web项目(非myeclipse)
    2015-11-04 报表(c#部分)(Datatable 查询,弹出日期控件,输入是否整数)
    2015-11-04 asp.net 弹出式日历控件 选择日期 Calendar控件
    JSP 资源与网站
    2015-09-17 001 存储过程数据操作类 H_data_Helper
    2015-09-17 001 日志与对话框公用类_public
    20150916_018 插入行()
    20150916_001 vba 基础
    20150825 C# 调用带参数的存储过程 模板
  • 原文地址:https://www.cnblogs.com/dongc/p/13995032.html
Copyright © 2011-2022 走看看