Help - Search - Members - Calendar
Full Version: Copying from CD with AUTOIT
MSFN Forums > Unattended Windows Discussion & Support > Application Installs

   


Google Internet Forums Unattended CD/DVD Guide
bigbroantonio
I'd like to copy files and dirs from a cd to various point of the hard drive. The problem is that I won't always be using drive D: or E: or whatever. So I'd like the script in some way to work out where it's running from and then copy the files from there (so if it's running on drive E: it will copy from there)

Things like

QUOTE
FileCopy("setup\file.exe","C:\windows\system32\")


just don't work. Even is the dir "setup" is there it seems to need a real path to the file/dir.

Thanks.
MHz
Sounds to me that the Working Directory is not the Script Directory, so your relative paths are failing.
When working relatively, you should check your Working Directory first before using the relative paths. FileChangeDir() can set your Working Directory.
As below, the script checks if the Working Directory is different to Script Directory, and if it is, then change Working Directory to the Script Directory.
CODE
If @WorkingDir <> @ScriptDir Then FileChangeDir(@ScriptDir)
FileCopy("setup\file.exe","C:\windows\system32\")


Or you can simply use the @ScriptDir macro. This is the fullpath to the script as shown below.
CODE
FileCopy(@ScriptDir & "\setup\file.exe","C:\windows\system32\")

If @ScriptDir is "E:\folder" then the 1st parameter would evaluate to "E:\folder\setup\file.exe"
smile.gif
Dumpy Dooby
Mhz, I often wonder if scout the forums for AutoIt threads. You always give the best, and most expedient, reponses. tongue.gif
MHz
QUOTE (Dumpy Dooby @ Jan 26 2006, 01:59 PM) *
Mhz, I often wonder if scout the forums for AutoIt threads. You always give the best, and most expedient, reponses. tongue.gif

Indeed scout is recommended, as I tire of giving the same good responses over and over. Thanks, I will accept your last line as a nice compliment.
smile.gif

@bigbroantonio
You should set your 2nd parameter with a macro as well. Just incase the path can be different for some reason.
example:
CODE
FileCopy(@ScriptDir & "\setup\file.exe", @SystemDir & '\')

newwink.gif
bigbroantonio
Thanks for your replies, MHz.

I'll check to it as soon as I can, and get back to you with my results.

I didn't really understand the "scout the forums" bit. Do you mean searching in the forums. I did have a look before posting, but couldn't really find anything - or maybe I didn't look hard enough.

Thanks again
MHz
QUOTE (bigbroantonio @ Jan 28 2006, 11:27 PM) *
I didn't really understand the "scout the forums" bit. Do you mean searching in the forums. I did have a look before posting, but couldn't really find anything - or maybe I didn't look hard enough.

Yeah, to scout is baxically to search, but that is fine. I do not believe that I or anyone else has explained the working directory to a meanful concept. I use the working directory and change directory often in scripts to make handling tasks easier. newwink.gif
Dumpy Dooby
QUOTE (bigbroantonio @ Jan 28 2006, 05:27 AM) *
Thanks for your replies, MHz.

I'll check to it as soon as I can, and get back to you with my results.

I didn't really understand the "scout the forums" bit. Do you mean searching in the forums. I did have a look before posting, but couldn't really find anything - or maybe I didn't look hard enough.

Thanks again

Oh, that wasn't directed at you. I was asking MHz if he searches the forum for AutoIt threads, since he always provides a swift and accurate response in the them. newwink.gif
RogueSpear
I came up with this little snippet for detecting the drive with your Windows CD in it:
CODE
For $drive = 65 to 90
    If FileExists(chr($drive) & ":\WIN51IP.SP2") Then $OEM = chr($drive) & ":\OEM"
Next

You wouldn't believe it but it took me several hours to figure this one out tongue.gif Oh yea, actually that code up there detects which drive, but it also sets a variable for the directory \OEM on the CD.
MHz
QUOTE (RogueSpear @ Jan 30 2006, 04:18 AM) *
I came up with this little snippet for detecting the drive with your Windows CD in it:
CODE
For $drive = 65 to 90
    If FileExists(chr($drive) & ":\WIN51IP.SP2") Then $OEM = chr($drive) & ":\OEM"
Next

You wouldn't believe it but it took me several hours to figure this one out tongue.gif Oh yea, actually that code up there detects which drive, but it also sets a variable for the directory \OEM on the CD.

AutoIt uses DriveGetDrive() to retrieve drive letters. Here is a User Defined Function that will provide the path to the $OEM$ folder on a CD in $variable.
CODE
$variable = _Drive()
MsgBox(0, 'Drive Letter', $variable)

Func _Drive()
    $drive = DriveGetDrive('CDROM')
    If Not @error Then
        For $i = 1 To $drive[0]
            If FileExists($drive[$i] & '\WIN51IP.SP2') Then Return $drive[$i] & '\$OEM$'
        Next
    EndIf
EndFunc

More examples of DriveGetDrive() are available if searched. rolleyes.gif




Google Internet Forums Unattended CD/DVD Guide

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.