Start a Conversation

Unsolved

This post is more than 5 years old

S

21807

May 24th, 2015 08:00

Need Help Creating a Batch File

I'd like to create a batch file that I can have run by Task Scheduler. I'd like the batch file to create a new directory named with the current date in my F: drive and then to move a directory into the newly created directory. I'm hoping maybe there are batch file resources somewhere that might already have something like this created. Would appreciate any suggestions. Thanks.

7 Technologist

 • 

16.3K Posts

May 24th, 2015 13:00

The requirements are kind of obscure, so it is unlikely you'll find an existing script that will do just what you want ... you'll need to do some altering. Can I ask what it is you are trying to accomplish? Perhaps there is a better way to do it.

7 Technologist

 • 

16.3K Posts

May 24th, 2015 13:00

It's just that you said you were hoping something like this already was out there ... I was just saying that your requirements are not typical or common enough for there to be something out there that you could just download or copy and use. I can put something together for you, but what are you doing this for? What is your goal?

219 Posts

May 24th, 2015 13:00

Thanks Flash. You say "The requirements are kind of obscure....... Since I'm not as computer fluent as perhaps I should be, I thought I outlined what I want pretty well. Please be more specific about what's missing. Summary:

  • Want the batch file to be activated via Task Scheduler
  • Want the batch file to create new directory on F: Drive with current date as the name
  • Want the batch file to move a Folder into the newly created Folder.

I'll try to be more specific if you tell me what I've missed. Thanks.

219 Posts

May 24th, 2015 14:00

Flash, you've really got me struggling. I'm not trying to be disrespectful, but I've listed my objectives twice. I'm not sure what more you're looking for. It seems straightforward to me.

Background:

Every Sunday night I make a system image backup. After the backup is complete I move the image into a new Folder with the date as its name. I want to automate all that by creating a batch file and scheduling it to run each week after the system image is recorded. I don't think I've said anything different here. What do you need? How can I say it differently.

My problem with creating the batch file is naming the new Directory with the current date. Can you tell me how I can do that?

219 Posts

May 26th, 2015 14:00

Flash, any ideas or suggestions for me. Thanks.

7 Technologist

 • 

16.3K Posts

May 27th, 2015 23:00

Yes, that helps. You are trying to bypass the limitation of Windows Backup to give yourself more than one image backup to refer to. You can manage multiple backup images more easily through Task Scheduler to pretty much any schedule you like using the following command:

wbadmin start backup -backupTarget:\\SYSTEMNAME\DRIVELETTER$\FOLDER -include:C: -allCritical -quiet

If you really want to use a BAT file, you can assign the folder name as the current date using the following:

SET minnie=%date:~-10,2%%date:~-7,2%%date:~-4,4%
md E:\%minnie%

That will turn the current date into a string like 05272015 and create a folder using that string (E:\05272015 in this case).

219 Posts

May 28th, 2015 19:00

Flash, thanks for the reply. As usual, I need more help. You say 

.......................................... You can manage multiple backup images more easily through Task Scheduler to pretty much any schedule you like using the following command:

wbadmin start backup -backupTarget:\\SYSTEMNAME\DRIVELETTER$\FOLDER -include:C: -allCritical -quiet

  • For SYSTEMNAME, do I use Computer name that shows up on Control Panel\System and Security\System?
  • Where do I enter this command? I don't understand how this command relates to Task Scheduler.
  • Would appreciate it if you could elaborate.

Thanks.

7 Technologist

 • 

16.3K Posts

May 28th, 2015 22:00

You could put this in your batch file, then schedule your batch file to fire it off, but it's easier to just schedule the command itself. This can also be run on demand from an elevated command prompt.

SYSTEMNAME is the name of your computer - the name found on the System information page.

So, if the name of your computer is BOB-PC, you are saving the backups to the X: drive, in the Monday folder, your command would look like this:

wbadmin start backup -backupTarget:\\BOB-PC\X$\Monday -include:C: -allCritical -quiet

You enter this command on the Actions tab of the Task Scheduler in two parts:

wbadmin goes in the Program/Script section:
C:\Windows\System32\wbadmin.exe

The rest of it goes in the Add Arguments section:
start backup -backupTarget:\\BOB-PC\X$\Monday -include:C: -allCritical -quiet

219 Posts

May 29th, 2015 10:00

OK, thanks Flash. That was the level of detail I need. Now, for the Folder. In your example, did that command create Monday, and send the image to it? Or did I have to have a folder named Monday already there?

7 Technologist

 • 

16.3K Posts

May 29th, 2015 13:00

No, the folder already existed. It will not create the folder if it doesn't exist.

219 Posts

May 31st, 2015 14:00

OK Flash, I tried creating a Scheduled Task, following your instructions. I apparently messed some thing up. It didn't;t run. Please Take a look at the Details in the Task Actions and see if you can spot the reason it didn't run. Is there anything else I could provide that might shed some light on why it didn't run?

Edit: I corrected the spelling from target to target and tried again. It still didn't run. It still shows the result of the last run as 0xFFFFFFFF,

7 Technologist

 • 

16.3K Posts

June 3rd, 2015 22:00

Sorry for the delay getting back to you. Given the correction of the spelling of "target", -backupTarget is all one word (no space between 'backup' and 'target'.

219 Posts

June 5th, 2015 17:00

OK, thanks Flash. I decided this isn't what I wanted to do. My backup process currently backs up selected folders and creates a system image. It's only the system image I want to move to an image library, not both the folders and system image. So I'm back to wanting what I originally said, an automated process, i.e. Task Scheduler initiated, that will look for a System Image in a specific location, find the date of the System Image, then create a new folder (in the Image Library), assign the date of the System Image file to the new folder, then move the System Image to the new folder. Got any new suggestions?

No Events found!

Top