• bat文件判断path路径是否包含其他路径


    1、

    直接上项目中代码,实际中如果电脑缺少C:\Windows\System32路径的话,下面的程序也无法运行,因为cmd中的一些命令需要该路径下的一些文件

    @echo off

    @set Path_=C:\Windows\System32 ::设置Path_为你想要的路径
    echo %Path%|find /i "%Path_%" && set IsNull=true|| set IsNull=false ::判断 Path是否包含Path_
    if not %IsNull%==true (

    ::如果不包含,在Path末尾加上Path_

    reg add "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment" /v Path /t REG_EXPAND_SZ /d "%Path%;%Path_%" /f
    )

    下面代码为项目中使用到的MSCOMM32.OCX控件,因为有的电脑上并没有安装该控件,所以在这里判断电脑系统种类进行复制和注册

    if exist C:\Windows\SysWOW64 (
    copy %~dp0\MSCOMM32.OCX C:\Windows\SysWOW64\MSCOMM32.OCX.
    regsvr32 C:\Windows\SysWOW64\MSCOMM32.OCX.
    ) else (
    copy %~dp0\MSCOMM32.OCX C:\Windows\System32\MSCOMM32.OCX.
    regsvr32 C:\Windows\System32\MSCOMM32.OCX.
    )

    2、

    @echo off
    set a=55544333
    set c=6666dfsfds
    set b=44
    echo %a%| findstr %b% >nul && (
        echo %a%包含%b%
    ) || (
        echo %a%不包含%b%
    )
    echo %c%| findstr %b% >nul && (
        echo %c%包含%b%
    ) || (
        echo %c%不包含%b%
    )
    
    pause

    https://blog.csdn.net/z5622139/article/details/65446144

    https://www.cnblogs.com/xiaostudy/p/11771959.html

  • 相关阅读:
    Leetcode 171. Excel Sheet Column Number
    Leetcode 206 Reverse Linked List
    Leetcode 147. Insertion Sort List
    小明一家人过桥
    Leetcode 125. Valid Palindrome
    Leetcode 237. Delete Node in a Linked List
    Leetcode 167 Two Sum II
    张老师的生日
    Leetcode 27. Remove Element
    Leetcode 283. Move Zeroes
  • 原文地址:https://www.cnblogs.com/onelikeone/p/16023875.html
Copyright © 2020-2023  润新知