Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


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

11 Nov 2010   #1
beidog

Windows 7 Ultimate x64
 
 
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 System SpecsSystem Spec
11 Nov 2010   #2
Ztruker

Windows 8 Core X64
 
 

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 System SpecsSystem Spec
11 Nov 2010   #3
Lemur

Systems 1 and 2: Windows 7 Enterprise x64, Win 8 Developer
 
 

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 System SpecsSystem Spec
12 Nov 2010   #4
beidog

Windows 7 Ultimate x64
 
 

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 System SpecsSystem Spec
12 Nov 2010   #5
Dwarf

Windows 8.1 Pro RTM x64
 
 

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 System SpecsSystem Spec
12 Nov 2010   #6
Lemur

Systems 1 and 2: Windows 7 Enterprise x64, Win 8 Developer
 
 

Agree with Dwarf. You should be able to disable, then re-enable a service from a batch file.
My System SpecsSystem Spec
12 Nov 2010   #7
Ztruker

Windows 8 Core X64
 
 

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 System SpecsSystem Spec
Reply

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




Thread Tools





Similar help and support threads
Thread Forum
Batch file to Sort and Move specific files by identifying word inside
Hi All... I will explain what I need in as much detail as possible. I need a batch file to move specific files into a separate folder,possibly by opening my hex editor,searching for the word "body" ( without the quotes ) and if found ,close hex editor,move file to a folder called "moved" ,then go...
General Discussion
Using notepad(batch programing) to execute a comand at a specific time
Can anyone help me make a command using notepad that can execute a task at a given time?
System Security
Batch file to automatically log a user off after a time of inactivity
Those of you who have read my posts over the past couple of weeks know what am doing on a computer belonging to an Assisted Living facility. I have the user accounts set up plus I have removed the "Switch User and Sleep menu items from the context menu of "START.......SHUTDOWN. I have reminded the...
General Discussion
Batch File that grabs file names from folder to insert into batch file
Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can... :confused: First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg. Here's the code that I'm using: ffmpeg -i...
General Discussion
DOS Batch - Forfiles - deleting specific file extensions
Hey all. I've reviewed several different examples of how forfiles works. To set the stage, I need to automatically remove files with a file extension of .0 followed by numbers that increment and these files would be 7 days or older. Unfortunately, none of the examples or forfiles /? usage...
Customization
Batch file to create a folder with name of the time.
I'm trying to write a batch file that when run creates a folder named "Backup" followed by the time it was created, and then copies files to that folder. When I run md "C:\Users\MasterControlProgram\Documents\MC Server With Backup\Backups\Backup %DATE%\" xcopy /e /v /y...
Backup and Restore

Our Sites

Site Links

About Us

Find 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 11:00.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App