Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Apr 2005
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Batch to Shutdown

    I have made a batch script that will remotely shut down pc's however is there a way i can add a timeout to it and also to avoid it if the pc is running a certain application?

    the following is my code


    Code:
    @echo off
    echo WARNING! This will shutdown all machines currently swiched on.
    echo Do you wish to continue?
    echo.
    pause
    
    shutdown -s -m 11.11.11.11 -f -c "Please ensure your machine is switched off before you leave your workstation.  Shutdown will commence shortly."
    
    echo.
    echo Process Complete.
    pause

  • #2
    New Coder
    Join Date
    Nov 2002
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can use pslist and redirect the output to a txt file. Once you have the list of process use some logic to see if the app your looking for is running and go from there.

  • #3
    New Coder
    Join Date
    Apr 2005
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    how do i redirect the output to a text file?

  • #4
    New Coder
    Join Date
    Nov 2002
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    pslist.exe > testfile.txt

  • #5
    New Coder
    Join Date
    Apr 2005
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK that worked like a charm,
    how do i get it to look through that to say find... word.exe?

  • #6
    New Coder
    Join Date
    Nov 2002
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Searches for a text string in a file or files.

    FIND [/V] [/C] [/N] [/I] [/OFF[LINE]] "string" [[drive:][path]filename[ ...]]

    /V Displays all lines NOT containing the specified string.
    /C Displays only the count of lines containing the string.
    /N Displays line numbers with the displayed lines.
    /I Ignores the case of characters when searching for the string.
    /OFF[LINE] Do not skip files with offline attribute set.
    "string" Specifies the text string to find.
    [drive:][path]filename
    Specifies a file or files to search.

    If a path is not specified, FIND searches the text typed at the prompt
    or piped from another command.

  • #7
    New Coder
    Join Date
    Apr 2005
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How would I use a conditional statement once its found the line?


  •  

    Posting Permissions

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