Post subject: Visual Basic 6, BATCH files, and Windows XP
Sir_VG
He/Him
Player (40)
Joined: 10/9/2004
Posts: 1914
Location: Floating Tower
I've developed a program in VB6 that uses BATCH files to do stuff like launch Excel files, do 7z compression, etc. But I've run into an odd problem, that maybe somebody can help me shed some light on. For some odd reason, despite that the same program is running on 3 different computers (all using XP), one computer works perfectly fine, one occassionally has an issue, and the 3rd breaks every time at the same point (when I do a weekly file backup function, but every other day works fine). What happens is that at one point in the program, whenever a BATCH file is suppose to be launched, either it doesn't appear (in the case of the 7z command), or it will flash the DOS box and not do anything at all. It's a serious problem, because when it's trying to do the 7z command, it causes a preprogrammed error message to appear, though oddly we've actually gone well past when that message shouldn't be applying anymore (since the file does exist, and the on error command has been changed TWICE). The kicker? You can actually go into Explorer and manually run the BATCH file itself. I'm not sure what's causing this and it's driving me nuts. What would cause a VB6 program (on XP) to misbehave like this...and on top of that only on certain computers? I know this is a stretch to ask for (expecially w/o providing code), but I'm just looking for general ideas.
Taking over the world, one game at a time. Currently TASing: Nothing
Tub
Joined: 6/25/2005
Posts: 1377
VB6 and BATCH files. Two of your problems right there :p do you make sure that the current directory is set correctly before launching the batch file? you can also try to add a PAUSE command to the end of your batch file to keep the window open, allowing you to see the error messages.
m00
Banned User
Joined: 12/23/2004
Posts: 1850
It may also be a good idea to do a "cd" command before that pause for checking the directory, yes.
Perma-banned
Sir_VG
He/Him
Player (40)
Joined: 10/9/2004
Posts: 1914
Location: Floating Tower
Tub wrote:
VB6 and BATCH files. Two of your problems right there :p do you make sure that the current directory is set correctly before launching the batch file? you can also try to add a PAUSE command to the end of your batch file to keep the window open, allowing you to see the error messages.
You know, the directory thing could be the issue, given that it only happens on Weekly Backup days, which means the VB6 program jumps between two different drives. Though it still seems odd that it doesn't occur on all computers. That's something I could easily fix by changing how VB6 writes the BATCH file (print #1, "start " App.Path + "\pmr.xls") Thanks for the idea. I'll try that method when I get back home to my computer. Yes, I'm aware VB6 + BATCH files suck, but I'm not a C++ coder or anything like that. I use what I know and plus the simpler interface style of VB6 makes it easier for the people using the program, since some of them aren't very computer literate.
Taking over the world, one game at a time. Currently TASing: Nothing
Joined: 8/27/2006
Posts: 883
Actually with VB.net, you could have process.start(), and be able to handle the process easily. It's free and have almost the same syntax as vb6. Visual Basic Express
Sir_VG
He/Him
Player (40)
Joined: 10/9/2004
Posts: 1914
Location: Floating Tower
I've heard about VB.net, but I didn't (and still don't) have a copy of it. I'm also more familiar with VB6, but I would be willing to do a conversion if it doesn't take up too much time, but I'm more looking for a quick fix so I'm not having to go through some complicated mechanism every week. That's something I should look into for a long term fix.
Taking over the world, one game at a time. Currently TASing: Nothing
Sir_VG
He/Him
Player (40)
Joined: 10/9/2004
Posts: 1914
Location: Floating Tower
Well, I tried the quick fix by modifying how the BATCH file loads, by including the directory path to load the XLS file, but that didn't work - there's some issue with the program itself, I guess, since it just skipped it (today was the usual weekly backup time frame, so I got to test a possible fix today), just as it had the past two weeks. I'll dig a bit into the code itself now that I have another week, but I still don't quite get why one computer works right and another doesn't, but I'll keep hammering away at this. Eventually I should get to VB.net, but I just don't have time right now to do a quick convert, though I won't close the option completely.
Taking over the world, one game at a time. Currently TASing: Nothing
Tub
Joined: 6/25/2005
Posts: 1377
not sure what kind of complicated backup solution you need, but mine is a simple bash-script build like this. It'll first create snapshots of databases and emails to new directory on hard drive #1. Then it'll mirror the newly created snapshots and other important files to hard drive #2, using rsync.
#!/bin/bash

DESTINATION=/backups/$(date +%Y-%m-%d)/
mkdir -p $DESTINATION
cd $DESTINATION

MIRROR=/home/backups/

echo "Making a backup of all databases.."
for db in database1 database2 database3 ; do
        echo "$db.."
        mysqldump -uroot -pMyPassword $db | gzip >mysql_$db.sql.gz
done

echo "Making a backup of all emails.."
logger -p mail.warn "Shutting down dovecot for backups."
/etc/init.d/dovecot stop
tar cpvjf ./dovecot.tar.bz2 -C /var/mail/ dovecot
/etc/init.d/dovecot start

echo "Done, mirroring to $MIRROR."
logger -p user.notice "Weekly backups created. Mirroring.."

echo "backups.."
rsync -rltv --delete /backups/ $MIRROR/mysql_and_dovecot/
echo "audio.."
rsync -av --delete /home/shared/audio/ $MIRROR/audio
echo "storage.."
rsync -av --delete --exclude=_unsorted /home/shared/archives/ $MIRROR/archives
# further directories to mirror go here

logger -p user.notice "Important files mirrored to $MIRROR."
exit
my real setup is a bit more complicated, because it has to manage three computers with 8 hard drives, and my policy is to have all important data backed up on two different physical machines. So there are additional scripts mirroring the files across computers (rsync + nfs-mount) as well as doing daily manual synchronisation of work data between notebook & workstation using unison. I guess you could solve most of your problems by looking at rsync (unidirectional synchronisation) and unison (bidirectional synchronisation), and writing some very simple scripts around them. No idea why you should need to launch XLS files for that..
m00
Sir_VG
He/Him
Player (40)
Joined: 10/9/2004
Posts: 1914
Location: Floating Tower
Actually, the start command (uses to launch XLS) is not used with backups. I just use filecopy commands for that. The issue is that the weekly backup function causes everything else BATCH related to break. I have one idea I ran across while comparing my Beta (where it never broke) and my v1.0.1 (where it's always breaking). For the file listing on the local drive, I don't throw in an App.Path command, which could be the issue. That's really the only difference between my Beta and my v1.0.1.
Taking over the world, one game at a time. Currently TASing: Nothing
Sir_VG
He/Him
Player (40)
Joined: 10/9/2004
Posts: 1914
Location: Floating Tower
I got it fixed. Basically, I just needed to throw around App.Path around more then I was using it. I guess going between two different locations (since backups are done on a different drive all together), I guess that was confusing the program. It all seems to work now. w00t! That big headache is over. Now to rest until the next one... ^^;;
Taking over the world, one game at a time. Currently TASing: Nothing