1.

Solve : Varible Drives Unknown?

Answer»

Normally a pc should have a drive C:

But how do you allow other drive letters in your code in a batch FILE

Say if you made copy C:\myfoler C:\myfolder
but they didnt have a C:\ only an E:\
how would you allow for different drives?

Then next, what if you had a mapped drive and the other pc was off, how would you stop the rest off the code from running after the copying failed?I'm not sure I understand the first part of your question. You can use any available drive letters in your batch file as you have them listed here. Like
Code: [Select]copy c:\myfolder e:\myfolder Or maybe I don't understand? Can you please explain:
Quote

Normally a pc should have a drive C:

But how do you allow other drive letters in your code in a batch file

Say if you made copy C:\myfoler C:\myfolder
but they didnt have a C:\ only an E:\
how would you allow for different drives?

For the network drive, you can do an IF test first. For example, if your network drive is Z:, you could do:
Code: [Select]if not exist z:\ echo Network drive not found&goto :EOF
echo Network drive found, running rest of batch fileI am good at confusing people today.

This batch file will be put on different pc's, and I KNOW from WORKING on pc's that sometimes someone might set a local drive on a pc to E:\ instead of C:\.
I have installed SCSI drives before and sometimes you cannot change the drive path of E:\ to C:\.

Only 1 hard drive with an only 1 unkown directory
(unknown being in your code)
C:\ maybe
D:\ maybe
E:\ maybe
etc.

I am wanting to make 1 batch file to use on all of the pc's here and I would like not have to modify it because of a pc not having a drive C:\. When you have a lot of pc's to tend to sometimes you forget whos got what.

What I am getting to is
is there a WAY to specify an unknown local drive.
If your code refers to drive C:\ and there ISNT one, only a drive E:\

I wonder if you could use an if statement to check for drive letters, or is there a better way?

Hope this helpsUse the %systemdrive% variable.
Try this in a batch file (or the command prompt):
Code: [Select]@echo My computer is running Windows from the %systemdrive% drive.That will do the trick
Your the Man!Thanks!


Discussion

No Comment Found