MSFN Forum: Copying from CD with AUTOIT - MSFN Forum

Jump to content



Unattended CD/DVD Guide Homepage · MSFN Forum Rules

Welcome to the Applications Installs forum. Make sure you read the forum rules before you start posting.

Links/Requests to warez and/or any illegal material (porn, cracks, serials, etc..) will not be tolerated. Discussion of circumventing WGA/activation/timebombs/keygens or any other illegal activity will also not be tolerated.

We try our best to keep this forum clean of illegal content. If you see any illegal activity use the "report" button you find in every post to report the specific post to the moderators. If you ignore any of the rules you will be banned without notice.

Read Forum Rules
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Copying from CD with AUTOIT Rate Topic: -----

#1 User is offline   bigbroantonio 

  • Newbie
  • Group: Members
  • Posts: 20
  • Joined: 26-September 05

Posted 25 January 2006 - 06:06 AM

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.


#2 User is offline   MHz 

  • SendToA3X v1.7
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,634
  • Joined: 02-August 04

Posted 25 January 2006 - 09:30 PM

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.
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.
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"
:)

#3 User is offline   Dumpy Dooby 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 424
  • Joined: 16-May 05

Posted 25 January 2006 - 09:59 PM

Mhz, I often wonder if scout the forums for AutoIt threads. You always give the best, and most expedient, reponses. :P

#4 User is offline   MHz 

  • SendToA3X v1.7
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,634
  • Joined: 02-August 04

Posted 25 January 2006 - 10:21 PM

View PostDumpy Dooby, on Jan 26 2006, 01:59 PM, said:

Mhz, I often wonder if scout the forums for AutoIt threads. You always give the best, and most expedient, reponses. :P

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.
:)

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

;)

#5 User is offline   bigbroantonio 

  • Newbie
  • Group: Members
  • Posts: 20
  • Joined: 26-September 05

Posted 28 January 2006 - 07: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

#6 User is offline   MHz 

  • SendToA3X v1.7
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,634
  • Joined: 02-August 04

Posted 28 January 2006 - 09:46 PM

View Postbigbroantonio, on Jan 28 2006, 11:27 PM, said:

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. ;)

#7 User is offline   Dumpy Dooby 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 424
  • Joined: 16-May 05

Posted 29 January 2006 - 12:04 PM

View Postbigbroantonio, on Jan 28 2006, 05:27 AM, said:

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. ;)

#8 User is offline   RogueSpear 

  • OS: SimplyMEPIS
  • Group: Supreme Sponsor
  • Posts: 1,529
  • Joined: 18-September 04

Posted 29 January 2006 - 12:18 PM

I came up with this little snippet for detecting the drive with your Windows CD in it:
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 :P Oh yea, actually that code up there detects which drive, but it also sets a variable for the directory \OEM on the CD.

#9 User is offline   MHz 

  • SendToA3X v1.7
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,634
  • Joined: 02-August 04

Posted 30 January 2006 - 08:25 AM

View PostRogueSpear, on Jan 30 2006, 04:18 AM, said:

I came up with this little snippet for detecting the drive with your Windows CD in it:
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 :P 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.
$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:

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy