WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

DirChange versus LogDisk functions

Keywords:    dirchange logdisk

Question:

I've written a couple of Winbatch scripts. The first of which is like a loader program, that copies the second compiled Winbatch script from the A: drive to the C: drive, and then starts to run a bunch of stuff. It works fine, until the end of the script, when, even though I've done a Dirchange("C:\") as my final line of code, it's acting like I'm still logged to the A: drive, and then hangs with the Blue Screen of Death. Ideas?

Answer:

I think that your problem is a DOS problem more than a WinBatch problem. The real issue here is where the Winbatch script is running from and the default drive. The DirChange command that you are using does NOT change the default drive. In order to do this within Winbatch, you MUST use the LogDisk command to set the default drive.

The easiest way to demonstrate this is to go to a DOS prompt and try the following commands with your diskette inserted in drive A:

	C: {ENTER}
	CD A:\DirChange {ENTER}

	A: {ENTER}
	CD C:\TEMP {ENTER}
You will notice that when you use the CD command with a drive letter parameter (equivalent to the DirChange command) the Default Drive does NOT change, the directory changes on the drive you have referenced but NOTHING changes on the current, default drive. In order to change the default drive, you MUST use a drive letter (colon) followed by an ENTER. There can be NO other parameters on the line! This is the same as the LogDisk command.

The other issue you have is where the program is running from. If you start the program from the A: drive, then you MUST leave the diskette in the drive, or get an error when it tries to run anything. The trick here is to force the program to change the drive it runs from (if you want to remove the floppy) by starting from another program (or batch file) which copies the required program to a directory on the hard drive and then “jumps” to it to run. You cannot use a Call or anything similar as it will want to go back to the original; you must leave the original program and start the new program on the new drive.

The other thing to watch for if you are booting from a floppy is the COMSPEC. We have some boot diskettes here that we remove after they have booted and started to run their program. The trick is to make sure that you have the same version of COMMAND.COM on a directory of the hard drive that you can transfer to. The easiest way to do this is to copy COMMAND.COM to the C:\TEMP directory and then use the COMSPEC=C:\TEMP\COMMAND.COM command to change the focus away from the floppy drive.

If you fail to do ALL of these steps, you will ALWAYS get errors when the system tries to access the removed floppy disk.


Article ID:   W13048
Filename:   Dirchange versus LogDisk.txt
File Created: 1999:04:15:16:51:24
Last Updated: 1999:04:15:16:51:24