Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with another batch file

Status
Not open for further replies.

apocalypse11

Technical User
Jan 11, 2001
77
0
0
AU
Hello everyone... i have some questions about a batch file that does a copy to another folder with the date. please see below:

@echo off
:: variables
set drive=C:\Folder
set folder=%date%
set backupcmd=xcopy /s /c /d /e /h /i /r /k /y

echo ### Backing up directory...
%backupcmd% "C:\somedirectory" "%drive%\%folder%"

echo Backup Complete!
@pause

Questions:
1. When this batch file runs, it creates a folder with the Day, Day number, subfolder Month, subfolder year, then subfolder copy of "set drive". How can i make it so that the date is just one folder and a subfolder of what is being copied to it?
2. How can i modify this batch job to send a message to another pc via ip address to say "that the job has finish succesfully" if it completes; or that it failed if it returns error messages?

Thanks...
 
If you have the messenger service running on all machines then you can use the net send command.

net send [Machine Name or IP address] Message

e.g.

net send 192.168.0.10 "Job completed successfully"

or

net send Fred "Job completed successfully"

Another option would be to have the job create a file with the message on the other machine. On the message receiving machine create a scheduler entry that runs a batch file every x minutes that looks for that file and if it is present, display it and then delete it.

e.g.

if exist message.txt goto display
exit
:display
notepad message.txt
del message.txt
exit

Crude but should do what you require.


 

In answer to your second question, I think Net send would fullfil your requirement

Net send 'the pc name' 'the message'
 
Hi & thanks for the tips...

also, i found the answer to question 1:

add this line
FOR /F "TOKENS=2-4 DELIMS=/ " %%a IN ("%date%") DO SET dd=%%a&SET mm=%%b&SET yy=%%c

and change this line to
set folder=%dd%-%mm%-%yy%
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top