4 Replies Latest reply on Dec 12, 2006 7:19 AM by BosDog

    Batch file to start and stop services

      I've setup a CF Probe on my Development Server to ensure my CF Production server is up and running (services = Apache and CF Application Server). It checks the PROD login page and if it times out in 30 sec the probe fails. I understand I can execute a file (batch file with net start and net stop) but the problem is I need to have the probe somehow point to the .bat file on the PROD server and not on the local machine. How can I remotely access this batch file and execute it? I don't know how to point to the file on the other server... can anyone help?
        • 1. Re: Batch file to start and stop services
          Level 7
          I would presume you would use a UNC path: \\server\directory\file.

          Of course any CF running this code would have to running as a user that
          has permissions to read this path.
          • 2. Re: Batch file to start and stop services
            ksmith Level 1
            That will still execute on the development server, regardless of the file path. A simple batch is not your answer. Have a look at psservice.exe from SysInternals.
            • 3. Re: Batch file to start and stop services
              ksmith Level 1
              Hi Ken,
              You had pointed me in the right direction regarding the psstools in order to create a batch file that can remotely start and stop services.

              i used the psexec command and am able to successfully restart the services needed remotely... however when i pick the file in the coldfusion administrator (in the probes section) how to i point to the batch file to run? it seems like the probe is not running the script like i want... the file is located on the c:\ so i entered c:\test2.bat...



              You should review the online help in the cfadmin for probes and the links it points you to in the developer's guide. Basically you need to define a new probe in the cfadmin by clicking the "Define New Probe" button. One of the probe's attributes will be what action. Define the action as a program and point it at a batch file running psexec. You will probably need to run CFMX as a specific user and not as localsystem, which is the default.
              • 4. Re: Batch file to start and stop services
                BosDog Level 1
                here is what i am doing to test it. i created a file called test2.bat which contains the command "del test.txt" (test.txt contains 3 letters abc). i then run a file called test3.cfm with the following code:

                <cfexecute name="d:\test2.bat">

                then when i look on the d: drive test.txt does not get deleted. i get no coldfusion errors so it appears the bat file runs. when i click and run the bat file manually it does what its supposed to and deletes test.txt file (which is within the same directory as the bat file). so the problem is that the bat file is not doing the commands its supposed to when coldfusion executes it... what do you suppose is wrong? i also followed the link in your previous help and setup a coldfusion user the way it told me to.