NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.
Forum Discussion
Sandshark
Dec 30, 2018Sensei - Experienced User
A Windows backup script you can use -- a gift from me to you
I have created a batch file that you can run interactively or call from the Windows Task Scheduler to backup your Windows Users folder (or any other, if that's your choice). It uses the free programs...
StephenB
Dec 31, 2018Guru - Experienced User
Thx for posting.
The forum software turned two text strings into emoticons, which of course won't work. I took the liberty of bolding the two :s that triggered this, so users can cut/paste the bat file into notepad with no problems.
Sandshark
Jan 01, 2019Sensei - Experienced User
Thanks. Yeah, that would have thrown some folks off.
Wow, it does that when you put it in a CODE box? Just one more thing that makes this really bad software. And it doesn't show you them when you edit, either -- so make that two more things.
There is one more thing I decided I should add to help in troubleshooting. While I said to use a drive mapping the you don't use for anything else, it turns out that having a window open to the target NAS folder, even if not mapped, causes an error I can't avoid. But changing line 74 as follows (adding the 2>>&1) will at least put the relevant information in the log:
NET USE %MapDrive% "\\%NASIP%\%NASDir%" /PERSISTENT:NO /USER:%NASUser% %NASUserPW% >>"%~dp0BULog.txt" 2>>&1
Thanks, too, for the info that bolding can work around the problem. I'll have to look out for the conversion and use that if there is a next time.
- StephenBJan 01, 2019Guru - Experienced User
Sandshark wrote:
Thanks. Yeah, that would have thrown some folks off.
Wow, it does that when you put it in a CODE box? Just one more thing that makes this really bad software. And it doesn't show you them when you edit, either -- so make that two more things.
Yes, it is a pain, and it really shouldn't do that in a code box. :smileyfrustrated:
Overall, there's no need to render the common emoticon abbreviations as emoticons anywhere in the posts, since it's easy enough to use the menu to add emoticons if you want them - and the menus don't use those abbreviations, they use strings like :smileyfrustrated: . Bolding part of the string is the only workaround I've found, and bolding the : doesn't stand out.
- SandsharkJan 02, 2019Sensei - Experienced User
OK, a couple more small changes. If you follow the instructions and never use the mapped drive letter for anything else, all will be well without this change. But I got to testing some "I didn't fully understand the instructions" scenarios and found that a previously mapped drive with the same letter and a folder or file in use will cause it to hang waiting for a response to force closure . And if the user gave the wrong response, it could run (and end up deleting files) in that "wrong drive". Even worse, if you happen to have a real drive with that letter, the same thing could happen on that drive instead of the mapped one, and it requires no user response. I also added error logging for these scenarios.
So, replace lines 72-75 with this:
NET USE %MapDrive% /DELETE /Y >>"%~dp0BULog.txt" ECHO Mapping "\\%NASIP%\%NASDir%" to %MapDrive% >>"%~dp0BULog.txt" NET USE %MapDrive% "\\%NASIP%\%NASDir%" /PERSISTENT:NO /USER:%NASUser% %NASUserPW% >>"%~dp0BULog.txt" 2>>&1 IF Errorlevel 1 GOTO Done
Specific changes are shown in red. I don't know how it could ever get to the second NET USE and still have another mapped drive to the same letter exist. But in case there is a scenario I haven't though of that can make that occur, this also fixes that.
If you prefer the "belt and suspenders" approach, leave in the old line 75 (IF NOT EXIST...) after the new one above.
I borrowed a lot of this from a script I wrote for work some time ago that runs on a user account that's never actively logged in and the computer is locked up where USB drives can never be inserted, so these scenarios could never exist there. Hopefully, I've now got all bases covered for more common users.
StephenB, maybe you can put this into the original? This change includes the last one.
BTW, for those who thought the batch file "language" was dead, this certainly shows otherwise, though a lot of the "magic" is done by RoboCopy (which can only be run from the command line and is well suited for use in batch files).
- StephenBJan 02, 2019Guru - Experienced User
Sandshark wrote:
StephenB, maybe you can put this into the original? This change includes the last one.
Done. Note I preserved the color coding, etc that is in the patch. Cutting/pasting to notepad will remove the formatting.
Sandshark wrote:
BTW, for those who thought the batch file "language" was dead, this certainly shows otherwise, though a lot of the "magic" is done by RoboCopy (which can only be run from the command line and is well suited for use in batch files).
I still have batch files I use routinely, you can do quite a lot with them. Powershell has more capabilities, but I haven't invested much time in learning it.
Related Content
NETGEAR Academy

Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology!
Join Us!