Sign in to follow this  
Followers 0
jtsteffen

Windows - No Disk error when running FileCopy

5 posts in this topic

I am attempting to write some error control in my program as I have found that if I attempt to copy a file from one drive to another that doesn't exist I get a "Windows - No Disk" error window that says: "Exception Processing Message c0000013 Parameters 75b6bf7c 4 75b6bf7c 75b6bf7c" <Cancel> <Try Again> <Continue>. I hit cancel and the mess comes back up again. I have to hit cancel three more times and then my error check comes up. I've looked for some threads that might discuss this issue but have been unable to find one.

Here is what I currently have for code for this section. How can I keep the Windows error from coming up? I suppose I could do some other check before doing the filecopy command.

Any help would be greatly appriciated. Thanks

CODE
Case $Msg2 = $OKButtonCDW

$DataDrive = GUICtrlRead ($DriveGUI)

GUIDelete($ChooseDriveWin)

SplashTextOn ( "Copying File", "Copying Simulator Program to Data Card" & @CR & @CR & "Sending Commands" & @CR &@CR & "Please Wait", 300,150)

$FileCopyErr = FileCopy ( "startRemoteSim", $DataDrive)

If $FileCopyErr = 0 Then ; something went wrong

SplashOff()

MsgBox(48, "Invalid Drive", "Unable to copy file to Data Card. Check that card is inserted and the correct drive letter was selected and try again." &@CR &@CR & "Press OK when ready to proceed.",-1,$MainWin)

ExitLoop

EndIf

SplashOff()

MsgBox(64, "File Copied", "The file has been copied. Eject Data Card from computer using proper procedures." &@CR &@CR & "Press OK when ready to proceed.",-1,$MainWin)

ExitLoop

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Can you post a totally self contained reproducer? I just tried a one line script with filecopy and it captures the failure properly, no error messages or whatever. Is it possible the drive does exist but something else is going on?

for what its worth here is the code I'm using;

$ret_val = FileCopy("notes.txt", "e:")
MsgBox(0, "", $ret_val)

EDIT: forgot to add code

Edited by someone

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites

I've provided the complete function below. When I select a drive that doesn't exist I still get the Windows error. However, I only get it once and when I hit Cancel it procedes to my error trap.

CODE
#include <GUIConstantsEx.au3>

#include <StaticConstants.au3>

#include <ButtonConstants.au3>

#include <Misc.au3>

; Button Handles

Global $OKButtonCDW, $CancelButtonCDW ; Buttons for Choose Drive GUI

; Declare Variables

; Declare GUI Variables

Global $Msg2 ; Variable handling GUI 2 Control

Global $ChooseDriveWin ; Handle on Choose Drive GUICreate

Global $DriveGUI ; Handle of Drive Selection

Global $FileCopyErr ; Handle for copying a file to check for errors

; Declare Program Variables

Global $DataDrive ; Drive Letter for Data Card

_LoadCard()

Func _LoadCard()

$ChooseDriveWin = GUICreate("Select Drive", 200, 150, -1, -1, -1, -1)

; Create Buttons and Check Boxes

$OKButtonCDW = GUICtrlCreateButton("OK", 15, 115, 75, 25)

$CancelButtonCDW = GUICtrlCreateButton("Cancel", 115, 115, 75, 25)

GUICtrlCreateLabel("Insert a blank Data Card into the Computer. Identify the Drive letter." &@CR &@CR & "Select the Drive letter that the Data Card is inserted in",15,5,170,75,$SS_CENTER)

$DriveGUI = GUICtrlCreateCombo("A:", 75, 75, 50, 15) ; create first item

GUICtrlSetData(-1, "B:|C:|D:|E:|F:|G:|H:|I:|J:|K:|L:|M:|N:|O:|P:|Q:|R:|S:|T:|U:|V:|W:|X:|Y:|Z:", "E:") ; add other item snd set a new default

; Show the GUICreate

GUISetState(@SW_SHOW)

While 1

$Msg2 = GUIGetMsg()

Select

Case $Msg2 = $CancelButtonCDW

GUIDelete($ChooseDriveWin)

ExitLoop

Case $Msg2 = $GUI_EVENT_CLOSE ; Closing the dialog box

GUIDelete($ChooseDriveWin)

ExitLoop

Case $Msg2 = $OKButtonCDW

$DataDrive = GUICtrlRead ($DriveGUI)

GUIDelete($ChooseDriveWin)

SplashTextOn ( "Copying File", "Copying Simulator Program to Data Card" & @CR & @CR & "Sending Commands" & @CR &@CR & "Please Wait", 300,150)

$FileCopyErr = FileCopy ( "startRemoteSim", $DataDrive)

If $FileCopyErr = 0 Then ; something went wrong

SplashOff()

MsgBox(48, "Invalid Drive", "Unable to copy file to Data Card. Check that card is inserted and the correct drive letter was selected and try again." &@CR &@CR & "Press OK when ready to proceed.",-1)

ExitLoop

EndIf

SplashOff()

MsgBox(64, "File Copied", "The file has been copied. Eject Data Card from computer using proper procedures." &@CR &@CR & "Press OK when ready to proceed.",-1)

ExitLoop

EndSelect

Wend

EndFunc

Share this post


Link to post
Share on other sites

I just figured out some more info on this issue. During the testing I was using an E: drive which I assumed did not exist on my computer. When I changed the drive to another one, the error trap worked just fine. I checked my computer and I found that there is a drive E: (removable) installed on this computer, however thiere is no disk inserted in it and so it cannot read it. When I try to open the drive in Explorer, Windows gave me "Insert Disk" error message.

I suspect that this is what we are running into here and it is just a coicidence that I happen to use the E: drive as a default. Even though this is unlikely to occure, I would like to see if I can come up with a solution to prevent it from happening. I hate bugs like these when I'm using software and try very hard to take into all possible senarios.

Any thoughts?

Share this post


Link to post
Share on other sites

Well I figured it out on my own. For those that care, I'll provide what I come up with.

I improved my script in a couple of ways. First of as I researched things I ran across a nice command called "DriveGetDrive" This allowed me to detect only the drives that were available instead of having to deal with a bunch of unknowns. I rewrote the script to search only for the removale drives and then list only those drives in my combo box.

Secondly I found the command "DriveStatus" which allowed me to check to see if the drive was ready to write or not. Since the drive was there, but there was no media in it, this allowed me to catch the error before the FileCopy command and thus stopped me from getting the Windows - No Disk error.

The modified code I came up with is as follows.

CODE
#include <GUIConstantsEx.au3>

#include <StaticConstants.au3>

#include <ButtonConstants.au3>

#include <Misc.au3>

; Button Handles

Global $OKButtonCDW, $CancelButtonCDW ; Buttons for Choose Drive GUI

; Declare Variables

; Declare GUI Variables

Global $Msg2 ; Variable handling GUI 2 Control

Global $ChooseDriveWin ; Handle on Choose Drive GUICreate

Global $DriveGUI ; Handle of Drive Selection

Global $FileCopyErr ; Handle for copying a file to check for errors

; Declare Program Variables

Global $DataDrive ; Drive Letter for Data Card

_LoadCard()

Func _LoadCard()

Local $DrivesAvailable ; list of drives available

Local $DriveList="" ; list of drives available

Local $X ; counter Var

; Find all the available "REMOVALBE" Drives

$DrivesAvailable = DriveGetDrive( "ALL" )

If @error Then

MsgBox(0, "No Drives Found", "No removable drives where detected." & @CR & @CR & "Please verify that a data card has been inseted into a Compact Flash Card Reader, the drive is active, and try again.")

Return

EndIf

For $X = 2 to $DrivesAvailable[0] ; create a string with all the drives

$DriveList = $DriveList & $DrivesAvailable[$X]

if $X < $DrivesAvailable [0] Then

$DriveList = $DriveList & "|" ; separate drives by pipe so they list separately in the combo box

EndIf

Next

; Create GUI

$ChooseDriveWin = GUICreate("Select Drive", 200, 150, -1, -1, -1, -1)

; Create Buttons and Combo Box

$OKButtonCDW = GUICtrlCreateButton("OK", 15, 115, 75, 25)

$CancelButtonCDW = GUICtrlCreateButton("Cancel", 115, 115, 75, 25)

GUICtrlCreateLabel("Insert a blank Data Card into the Computer. Identify the Drive letter." &@CR &@CR & "Select the Drive letter that the Data Card is inserted in",15,5,170,75,$SS_CENTER)

$DriveGUI = GUICtrlCreateCombo($DrivesAvailable[1], 75, 75, 50, 15) ; create first drive

GUICtrlSetData(-1, $DriveList, $DrivesAvailable[1]) ; add other drives snd set a new default

; Show the GUICreate

GUISetState(@SW_SHOW)

While 1

$Msg2 = GUIGetMsg()

Select

Case $Msg2 = $CancelButtonCDW

GUIDelete($ChooseDriveWin)

ExitLoop

Case $Msg2 = $GUI_EVENT_CLOSE ; Closing the dialog box

GUIDelete($ChooseDriveWin)

ExitLoop

Case $Msg2 = $OKButtonCDW

$DataDrive = GUICtrlRead ($DriveGUI)

GUIDelete($ChooseDriveWin)

If DriveStatus($DataDrive) <> "Ready" Then

MsgBox(48, "Drive not Ready", "Unable to copy file to Data Card. Check that card is inserted and the correct drive letter was selected and try again." &@CR &@CR & "Press OK when ready to proceed.",-1)

Return

EndIf

SplashTextOn ( "Copying File", "Copying Simulator Program to Data Card" & @CR & @CR & "Sending Commands" & @CR &@CR & "Please Wait", 300,150)

$FileCopyErr = FileCopy ( "startRemoteSim", $DataDrive)

If $FileCopyErr = 0 Then ; something went wrong

SplashOff()

MsgBox(48, "File Copy Error", "Unable to copy file to Data Card. Check that card is inserted and the correct drive letter was selected and try again." &@CR &@CR & "Press OK when ready to proceed.",-1)

ExitLoop

EndIf

SplashOff()

MsgBox(64, "File Copied", "The file has been copied. Eject Data Card from computer using proper procedures." &@CR &@CR & "Press OK when ready to proceed.",-1)

ExitLoop

EndSelect

Wend

EndFunc

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0