1 Reply Latest reply on Nov 13, 2013 2:01 PM by MarXtar

    Reboot if process is running?

    Rookie

      Hi all,

       

      First off - I'm new to these forums and to LANDesk - so apologies if this is a stupid question posted in the wrong place!

       

      I have been set a task where I need to scan several hundred machines and reboot them if a particular windows process is running... how would I best go about this from within LANDesk Management Console?

       

      I know I could write a chunk of vbscript to search the "local" PC for the process and then fire of a reboot if it is found, but I was wondering if there was a smarter or more efficient way of accomplishing this?

       

      Thanks in advance for any advice/support

        • 1. Re: Reboot if process is running?
          MarXtar ITSMMVPGroup

          It isn't a standard feature of LANDesk to do this so it would require a bit of scripting to achieve.

           

          Here is a reasonably simple batch file:

           

          @echo off

          set EXEC_CMD="notepad.exe"

          wmic process where (name=%EXEC_CMD%) get commandline | findstr /i %EXEC_CMD%> NUL

          if errorlevel 1 (

              echo Couldn't Find It!!!

          ) else (

              @echo Found It!! %EXEC_CMD%: is running.

          )

           

           

          replace notepad.exe with what you want (but use this as a simple test).

           

          If you are happy with the test then you could change it to something like this:

           

          @echo off

          set EXEC_CMD="notepad.exe"

          wmic process where (name=%EXEC_CMD%) get commandline | findstr /i %EXEC_CMD%> NUL

          if errorlevel 1 (

              echo Couldn't Find It!!!

                   sdclient.exe /msg="Process not found, exiting"

          ) else (

              @echo Found It!! %EXEC_CMD%: is running.

              sdclient.exe /msg="Found the running process. Starting to reboot"

               sdclient.exe /reboot

          )

           

           

          I haven't tested this last bit, but it is similar to what I've done in the past. It will update your task with a message saying what the result of the script was and if found cause the machine to reboot. All test was done on a Win7x64 system.

           

           

           

           

          Mark McGinn

          MarXtar Ltd/MarXtar Corporation

          http://landesk.marxtar.co.uk

          LANDesk Expert Solution Provider

           

           

          The One-Stop Shop for LANDesk Enhancements

          - Wake-On-WAN - Distributed Wake-On-LAN, Scheduled Power Down, and SWDist Sequencing

          - State Notifier - Real-Time Device & User State Inventory Updating & Alerting

          Update - New Stand-Alone State Notifier Console for Service Desk Operators

          Update - State Notifier now detects machine and user Idle states

          Update - WoW & State Notifier now integrate for even more functionality