Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Copying from CD with AUTOIT

Featured Replies

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

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.


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"

:)

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

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 & '\')

;)

  • Author

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

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

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

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.

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:

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.