jbennett Posted October 31, 2008 Share Posted October 31, 2008 (edited) Hi everyone, I seem to have a problem when using drivestatus to check a network storage drive. Basically my code checks the drive status and once it's found the drive it will proceed to a msgbox asking the user if they want to perform a backup. The problem is that my code will find the drive once it's connected and then display the msgbox asking if the user wants to perform the backup but when the user selects yes the program just exits. If I remove the drivestatus code and just have the msgbox to popup asking the user to perform the backup and then connect the network storage drive it works fine. I have pasted the function code below which is called from within the program and runs before proceeding to display the msgbox asking the user if they want to perform a backup. Does anyone know what may be wrong with the following code. Thanks Func _Check_Backup_Destination_Exists() $checkNASdrive = DriveStatus($backup_location) $iAsk = 0 While $checkNASdrive = "INVALID" If $iAsk = 0 Then $iAsk = MsgBox(1+16, "ERROR", _ "Cannot find backup destination" & @LF & _ "Please connect the backup drive and click the OK button") Else $iAsk = MsgBox(5+16, "ERROR", _ "Cannot find backup destination." & @LF & _ "Please wait 2/3 minutes after connecting the backup drive.") EndIf If $iAsk = 2 Then Exit WEnd EndFunc Edited October 31, 2008 by jbennett Link to comment Share on other sites More sharing options...
jbennett Posted October 31, 2008 Author Share Posted October 31, 2008 (edited) Hmm. I've tried to simplify the code but it now doesn't recognize that the NAS drive is connected when it's connected. I presume the "READY" status is not working. Any ideas would be much appreciated. Thanks $checkNASdrive = DriveStatus($backup_location) Do If $checkNASdrive = "INVALID" Then $msgcode = MsgBox(16 + 49, "ERROR", "Cannot find backup destination" & @LF & "Please connect the NAS drive and click the OK button") EndIf Until $checkNASdrive = "READY" Or $msgcode = 2 Edited October 31, 2008 by jbennett Link to comment Share on other sites More sharing options...
November Posted October 31, 2008 Share Posted October 31, 2008 Hi there, I made this one, and i had no trouble! $backup_location = "H:" while 1 $status = DriveStatus ( $backup_location) Select case $status = "INVALID" ConsoleWrite($status & @CRLF & "Waiting...") Case $status = "Ready" ConsoleWrite($status & @CRLF & "Exiting") Exit EndSelect Sleep(100) WEnd i hope this helps! Cheers Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font] Link to comment Share on other sites More sharing options...
jbennett Posted October 31, 2008 Author Share Posted October 31, 2008 (edited) Hi, Thanks for the post. This seems to work if I set it to other drives that are INVALID but the code doesn't do anything if I set it to the my Y: mapped drive. The code is running but nothing is happening? Any ideas what could be going wrong here. Thanks EDIT ---- I had to change INVALID to UNKNOWN which now works, but there seems to be about a 7 second delay. This is normal when I try to access the mapped drive myself. Is there any registry fixed to prevent windows from checking the drive for so long as it's really getting in the way of the code. $backup_location = "H:" while 1 $status = DriveStatus ( $backup_location) Select case $status = "UNKNOWN" ConsoleWrite($status & @CRLF & "Waiting...") Case $status = "Ready" ConsoleWrite($status & @CRLF & "Exiting") Exit EndSelect Sleep(100) WEnd Edited October 31, 2008 by jbennett Link to comment Share on other sites More sharing options...
jbennett Posted October 31, 2008 Author Share Posted October 31, 2008 (edited) The code seems to be working. The only problem I'm having is getting the code to release itself from the case so it can continue some other code. Does anyone know how I can get the code to continue if the drive is "READY" Thanks $backup_location = "C:" while 1 $status = DriveStatus ( $backup_location) Select case $status = "INVALID" MSGBOX(4096,"ERROR","Cannot find backup destination" & @LF & "Please connect the NAS drive and click the OK button",0) Case $status = "READY" if $status = "READY" then endif EndSelect Sleep(100) WEnd Edited October 31, 2008 by jbennett Link to comment Share on other sites More sharing options...
November Posted October 31, 2008 Share Posted October 31, 2008 The code seems to be working. The only problem I'm having is getting the code to release itself from the case so it can continue some other code. Does anyone know how I can get the code to continue if the drive is "READY" Thanks $backup_location = "C:" while 1 $status = DriveStatus ( $backup_location) Select case $status = "INVALID" MSGBOX(4096,"ERROR","Cannot find backup destination" & @LF & "Please connect the NAS drive and click the OK button",0) Case $status = "READY" if $status = "READY" then endif EndSelect Sleep(100) WEnd HI again, $backup_location = "C:" while 1 $status = DriveStatus ( $backup_location) Select case $status = "INVALID" MSGBOX(4096,"ERROR","Cannot find backup destination" & @LF & "Please connect the NAS drive and click the OK button",0) Case $status = "READY" Backup() EndSelect Sleep(100) WEnd Func backup() ;Backup function Endfunc Cheers Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now