zoukankan      html  css  js  c++  java
  • Useful bat command

    1.Start and stop the windows services


    net stop <service name>
    net start <service name>
    net pause <service name>
    net continue <service name>

    A full list of the exact services is found in the registry (run regedit.exe) under the HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServices key.

    Alternatively, you can perform the stop and start using the name that is showed in the Services Control Panel applet by putting the name in quotes, i.e.

    net stop "<service>"
    net start "<service>"

    2.Display all the Windows services.

    net star
    sc

    3. Query Windows Services status.

    net start | find "windwos services nname" 1>nul

    if not errorlevel 1 (

    echo "windwos services nname" already started.

    ) else (

    echo "windwos services nname" didn't started.

    )

    sc query "windwos services id"| find /C:"STATE" | find /C:"RUNNING" 1>nul

    if not errorlevel 1 (

    echo "windwos services nname" already started.

    ) else (

    echo "windwos services nname" didn't started.

    )

    4. Search String in a file. Findstr is what you needed.


    Use spaces to separate multiple search strings unless the argument is prefixed
    with /C.  For example, 'FINDSTR "hello there" x.y' searches for "hello" or
    "there" in file x.y.  'FINDSTR /C:"hello there" x.y' searches for
    "hello there" in file x.y.


    findstr /c "string" file
    if %errorlevel% equ 1 goto notfound
    echo found
    goto done
    :notfound
            echo notfound
            goto done
    :done

    Or something like: if not found write to file.
            findstr /c "%%P" file.txt  || ( echo %%P >> newfile.txt )

    Or something like: if found write to file.
            findstr /c "%%P" file.txt  && ( echo %%P >> newfile.txt )

    Or something like:
            findstr /c "%%P" file.txt  && ( echo found ) || ( echo not found )

  • 相关阅读:
    s3c2440的2440init.s的分析(转载)
    sql server错误状态列表(转载)
    vector类、迭代器、bitset类(转载)
    VC++以ADO方式连接SQL SERVER
    WinCE流设备驱动简介及GPIO驱动的实现(转载)
    .obj, .lib, .dll, .exe的关系(转载)
    利用DynamicExpression.ParseLambda实现Eval
    Matching Balanced Constructs with .NET Regular Expressions
    VB.NET and C# Comparison【转】
    ReportViewer一个简单例子
  • 原文地址:https://www.cnblogs.com/princessd8251/p/3935669.html
Copyright © 2011-2022 走看看