Storing a directory path in a variable - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Storing a directory path in a variable

jwondruschjwondrusch Posts: 1Member
Hi all - first post at programmersheaven.com!

I've been developing a small backup utility that relies on the 7-zip command line utility. It all works well but I'm hoping to streamline it a bit, as well as making it easier to update because it may be used in multiple locations and networks.

So my first question is, is it possible to store a directory path as a variable? For example, I'd like to be able to put C:Documents and SettingsUser NameDesktop into the variable %backupDir% but I've been able to use it as such. I'd like to use that to change to the directory i'm backing up via the cd command:

cd %backupDir%

I've tried using CHDIR as well, to no avail. I've tried using quotes, using %20 instead of spaces, tried using %userprofile% for the first part of the path and I haven't had any success using variables instead of absolute or relative paths. Please help?

The second question I have is regarding error catching. Is it possible to use batch to monitor the 7-zip utility and to cancel it if it encounters an error? or do I have to let it run the entire way and then cancel the results at the end?

Thanks for any help you may be able to ovver
Sign In or Register to comment.