• 获取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

    输出:

  • 相关阅读:
    字符串匹配的KMP算法
    附加数据库出错
    SQL Server 2005
    OpenFileDialog对话框Filter属性
    flink run 报错java.lang.NoSuchMethodError: org.apache.hadoop.ipc.Client.getRpcTimeout(Lorg/apache/hadoop/conf/Configuration;)I
    修改cdh5集群中主机节点IP或hostName
    oracle 自增序列 在 mybatis中应用
    org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
    java远程连接hadoop,kerbers认证失败 报no supported default etypes for default_tkt_enctypes
    hive distribute by sort by 去重
  • 原文地址:https://www.cnblogs.com/dongc/p/13995032.html
Copyright © 2020-2023  润新知