Results 1 to 3 of 3

Thread: Batch script Help

  1. #1
    Join Date
    Jul 2004
    Posts
    2,250
    Rep Power
    0

    Default Batch script Help

    Can someone assist me with this batch script. what i want to do is if the service is stop i want a echo message to print out saying starting dhcp. If the service is connected i want a message saying stopping dhcp. The script below work but not with the messages; i think i need to put it in a loop or something but im not good with scripting i found this sample on the net.


    sc query dhcp| findstr /i running | if "%errorlevel%"=="0" (sc stop dhcp) else (sc start dhcp)
    The price of anything is the amount of life you exchange for it.
    Henry David Thoreau

  2. #2
    Join Date
    Sep 2008
    Posts
    59
    Rep Power
    0

    Default

    what is this dos , why use echo to the screen , i would get a better motioning system that could work with conditions. like even whats up Gold

  3. #3
    Join Date
    Feb 2008
    Posts
    725
    Rep Power
    17

    Default

    I think you are looking for something like this

    Code:
    sc query dhcp | findstr /i running | if %errorlevel%==0 ( sc stop dhcp) else ( echo Process is running)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •