1.

Solve : Need help with batch file to backup user data?

Answer»

Hi All, I'm new to scripting and writing batch file. I would really appreciated if someone can help me with this batch file i'm working on. The purpose of this file is to backup the user data to a network location. As of now, it'll do it job of backing up. I NEED some minor tune up with the batch file.

Here's the batch file:

:MAP user U_DRIVE_ARCHIVE
net use k: \\htbwfs05\%username%_u$

Delay 20

:killing outlook process
taskkill -f -im outlook.exe

:Backup
cd C:\Program Files\Microsoft\SyncToy
Synctoy /min -R"Network Backup

if exist \\htbwfs05\%username%_u$\desktop goto continue

:next - Create desktop and favorites folder if does not exist
md \\htbwfs05\%username%_u$\desktop
md \\htbwfs05\%username%_u$\favorites

:continue - create zip file of desktop and favorites
set folder=%date:~10,4%%date:~4,2%%date:~7,2%
"C:\program Files\winzip\wzzip.exe" -a -p -r "K:\desktop\desktop%folder%.zip" "%userprofile%\desktop\."

set folder=%date:~10,4%%date:~4,2%%date:~7,2%
"C:\program Files\winzip\wzzip.exe" -a -p -r "K:\favorites\favorites%folder%.zip" "%userprofile%\favorites\."

:Remove map drive
net use K: /delete

:resume desktop
taskkill -f -im hidedesk.exe

pause

Here's are some question i have.
1. Is there a way i can set the focus on the hidedesk.exe window? as of now the hidedesk window will hide the desktop but once Synctoy kick in, it'll be on top of the hidedesk screensaver.
2.Is there away to do incremental backup to the user desktop/favorites folder beside using xcopy? The method im using above is what i got from reading a post from GuruGary(sp?). What it does is making a new zip file for every DAY that i'm running the batch file. The ideal thing that i hope it can do is to do incremental backup to the same zip file and change the date when i'm running it. Alternatively, i can just use the xcopy command to do incremental backup using the following command:
xcopy "%userprofile%\desktop\." /d /s /e /f /y "K:\desktop"
xcopy "%userprofile%\favorites\." /d /s /e /f /y "K:\favorites"

Any help would be much appreciated.Quote from: Stormryder on June 05, 2007, 11:28:50 AM

Here's are some question i have.
1. Is there a way i can set the focus on the hidedesk.exe window? as of now the hidedesk window will hide the desktop but once Synctoy kick in, it'll be on top of the hidedesk screensaver.
2.Is there away to do incremental backup to the user desktop/favorites folder beside using xcopy? The method im using above is what i got from reading a post from GuruGary(sp?). What it does is making a new zip file for every day that i'm running the batch file. The ideal thing that i hope it can do is to do incremental backup to the same zip file and change the date when i'm running it. Alternatively, i can just use the xcopy command to do incremental backup using the following command:
xcopy "%userprofile%\desktop\." /d /s /e /f /y "K:\desktop"
xcopy "%userprofile%\favorites\." /d /s /e /f /y "K:\favorites"
For question 1, try launching the "hidedesk.exe" program again. If that doesn't work, then try something like this (you may have to change the title depending on the actual title of the window):
Code: [Select]echo set WshShell = CREATEOBJECT("Wscrip.Shell") >ActHideDesk.vbs
echo WshShell.AppActivate "HideDesk" >>ActHideDesk.vbs
cscript ActHideDesk.vbsFor question 2, is there a reason you don't want to use XCOPY? The ZIP programs all work a little bit different, so WITHOUT knowing your brand and version there isn't an easy way to help you fix it. But it seems to me like the xcopy method should work well. If not, let us know why, or post the details of your zip program.Thank you for the reply.
My solution for the first question is by inserting a delay in the batch file that i use to open up the hidedesk.exe.
For the 2nd question, i guess i'll just have to use xcopy to do the incremental backup. Btw, the winzip version i'm using is WinZip 10.0.


Discussion

No Comment Found