Jump to content

Recommended Posts

Posted

The following function was written for an unfinished script to check for a installer file on a CD. I had someone request to make the script compatible to install the same program if the "CD" was instead on a network location. Would this function work properly if $CDDir was the network location instead of D:, and if not, which direction should I be looking in to make it work?:

;#############################################################################################

#####

;

; CDCheck Function

;

; Revision 3

; Last Edited September 11, 2005 for Falcon 4 Dance Partner version 1.1

; Written by David C. Reynolds

;

; - Checks for Falcon 4.0 CD installation file

;

; - Dependant Functions:

; VeriFile

;

; - Input Variables:

; none

;

; - Output Returns:

; "0" if unsuccessful or aborted

; "1" if successfully completed

; "2" to call the function to check again

;

;##################################################################################################

;__________________________________________________________________________________________________

; BEGIN CDCHECK FUNCTION-

Func CDCheck ()

;__________________________________________________________________________________________________

; DECLARE LOCAL VARIABLES-

; Control handle for the No CD message box:

Local $nocd

; File name of the Falcon 4 CD installer:

Local $installer

; Control handle for the No File message box:

Local $nofile

; Gets return from VeriFile function:

Local $verify

;__________________________________________________________________________________________________

; PRE-INSTALL CHECK-

; Check if CD is inserted:

If DriveStatus ($CDDir & "\") <> "READY" Then

$nocd = MsgBox (49, "Insert Falcon 4.0 Installation Disk", "Insert the Falcon 4.0 installation CD into the " & $CDDir & " drive. If the AutoPlay menu pops up, click ""Exit"".")

If $nocd = 1 Then

Return 2

Else

Return 0

EndIf

EndIf

; Get Falcon 4.0 Cd installer name:

$installer = GetInstallerName ("Install_F4CD")

; Check if Falcon 4.0 installation file exists:

If FileExists ($CDDir & "\" & $installer) <> 1 Then

$nofile = MsgBox (49, "Falcon 4.0 Installer Not Found", "The Falcon 4.0 installer " & $installer &" was not found on the CD in the " & $CDDir & " drive. Check to make sure the proper CD is inserted. (If the AutoPlay menu pops up, click ""Exit"")")

If $nofile = 1 Then

Return 2

Else

Return 0

EndIf

EndIf

; Check for proper Falcon 4.0 installaion file size:

$verify = VeriFile ($installer, (FileGetSize ($CDDir & "\" & $installer)))

If $verify = "0" Then

Return 0

EndIf

;__________________________________________________________________________________________________

; END CDCHECK FUNCTION:

Return 1

EndFunc[\code]

To clarify, the $CDDir variable is defined from a txt file which the EU would have entered "D:" for a cd drive, but could have otherwise entered a network location.

The GetInstallerName function will return the name of the installation exe, "setup.exe" (defines $installer)

The VeriFile function just checks for the proper size of the file, assume it is succesful.

After this function succesfully completes, Run ($CDDir & "\" & $installer) is called.

-DRX
Posted (edited)

I just tried calling DriveGetStatus("\\computer\share") within my own network and it returned READY. To me there are no other obvious parts of your code that would fail if using a network location.

As always however, the best way to know whether it would work on a network location is to try it out. ;)

Edit: Perhaps you might want to look at the content of the $cdDir variable and determine whether it points to a drive or a network share -- this will allow you to make the MsgBox() prompts more sensible given the situation.

Edited by LxP

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
×
×
  • Create New...