Help with Batch file, if statement in a specific time.


  1. Posts : 25
    Windows 7 Ultimate x64
       #1

    Help with Batch file, if statement in a specific time.


    hi, I am working on a batch file, such as

    [If Service A starts during 10pm-11pm, then stop Service A.]
    If this is not possible, then just simply,
    [If Service A starts, then stop Service A.]

    Thanks!
      My Computer


  2. Posts : 6,285
    Windows 10 Pro X64
       #2

    Need a bit more information.

    How is Service A being started?
    Will the batch file be run manually or from a scheduled entry?

    The simplest way to do this is to simply assume it's running and try to stop it.

    net stop "Service A"

    and not care if it gets an error or not. As I said, more info please.
      My Computer


  3. Posts : 3,139
    Systems 1 and 2: Windows 7 Enterprise x64, Win 8 Developer
       #3

    I'm a little confused as well. A batch file is run at one time, or are you planning to have the batch file run in a constant loop?
      My Computer


  4. Posts : 25
    Windows 7 Ultimate x64
    Thread Starter
       #4

    I am sorry for not providing enough infor.
    here is my story..... I am running a backup Service. let say this service starts at 10PM, when it runs at 5%, another service A will begins, and I have to stop this service A right away, otherwise, my backup service will fail. However, every time while it runs at 5%, it uses a unique amount of time.
    So how can I make this job complete?
    note:Service A is set to manual, and I don't want to disable it, since some other program may use it in different time.
      My Computer


  5. Posts : 9,582
    Windows 8.1 Pro RTM x64
       #5

    Do you need 'Service A' to run whilst you are running the backup Service? If not, create a batch file to disable it whilst you run the backup and then automatically reenable it when the backup is finished.

    Can you post the contents of the batch file as you have it so far?
      My Computer


  6. Posts : 3,139
    Systems 1 and 2: Windows 7 Enterprise x64, Win 8 Developer
       #6

    Agree with Dwarf. You should be able to disable, then re-enable a service from a batch file.
      My Computer


  7. Posts : 6,285
    Windows 10 Pro X64
       #7

    What software are you using for backup? Some allow you to run a command before and after the backup. You could then disable "Service A" at the start and enable it at the end.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 07:32.
Find Us