Re: check for drive letter before copying files.



Sorry - the EXIT was pseudocode - what you need to do there is either delete the "EXIT" and let the logic take over, or add some sort of jump or Return out of the entire routine.

GP

--->
On Apr 12, 10:19 am, GRAND_POOBAH
<iss_boss.del...@xxxxxxxxxxxxxxxxxxxx> wrote:
--->





On Apr 12, 9:51 am, GRAND_POOBAH
<iss_boss.del...@xxxxxxxxxxxxxxxxxxxx> wrote:
The only thing I can see is the extra "End If" noted.
GP
--->
hey all,
script newbie here and i am banging my head against my keyboard trying
to figure this one out. i am sure it is easy to all of the guru's
here. what i am trying to do is check to see if an assigned drive
letter (i: in this case) exists before i allow a script to copy data
to it. if it doesn't i want the script to continue as planned, if it
doesn't i want the script to prompt the end user to insert his/her usb
drive. i know there has to be a way to do it so any help would be
greatly appreciated. thanks in advance...
here is what i have so far.
Dim objfso, msg, i
drv = "i"
Set objfso = CreateObject("Scripting.FileSystemObject")
If objfso.DriveExists(drv) Then
End If <------------------------------------------------------------ HERE
Set i = objfso.GetDrive(drv)
If i.IsReady Then
Else
msg = "Please plug USB drive into laptop..."
End If
Else
msg = "Please plug USB drive into laptop..."
End If
Set objShell = CreateObject("Wscript.Shell")
objshell.Popup msg, AUTO_ANSWER, "Insert USB Drive", OK_Button- Hide quoted text -
- Show quoted text -
Thanks for the response. What I was trying to accomplish is for the
script to continue without any notification if the the drive exists.
I only want to be prompted if the drive letter doesn't exist. If I
remove that END IF it prompts me with a blank echo/msgbox and I have
to click ok. I don't want any user interaction unless the drive
doesn't exist. Any other ideas? Thanks ...
Your logic might go like this (this can be simplified with multiple
logic statements):

IF (drive exists) Then
IF (drive is ready) Then
' Do nothing - EXIT
ELSE
' wait until drive is ready
ENDIF
ELSE
' Tell OP to plug the drive in; and ...
' wait until drive is ready
ENDIF

GP- Hide quoted text -

- Show quoted text -

I thought I already responded but it isn't showing my last post so
here goes again. I apologize in advance if this comes up as a
duplicate. Following the logic you listed here is the script the way
I have it now. I am getting and invalid EXIT error when I try to run
it. Thanks for your continued efforts.

Dim objfso, msg, i
drv = "i"
Set objfso = CreateObject("Scripting.FileSystemObject")
If objfso.DriveExists(drv) Then
Set i = objfso.GetDrive(drv)
If i.IsReady Then
EXIT
Else
msg = "Please plug USB drive into laptop..."
End If
Else
msg = "Please plug USB drive into laptop..."
End If
Set objShell = CreateObject("Wscript.Shell")
objshell.Popup msg, AUTO_ANSWER, "Insert USB Drive", OK_Button

.


Loading