Jump to content

Copying files from a user's cd to their system32 directory


Recommended Posts

I was wondering if you could tell me how would you copy a files from a cd rom (not knowing the drive letter) to the system32 directory.

I have created a script to check for the lastest vulnerabilites and disable the wireless connections on notebooks as they enter our facility. The problem is I have 2 files that I need to complete this task.

A .vbs script and .exe. If at all possible I could run the script via referring to the files on the cd, I wouldn't have to worry about copying. Could this be possible? Otherwise I need to copy both files into system32 directory.

I am a newbie and would appreciate any help that you could provide.

Thanks!

Link to comment
Share on other sites

I was wondering if you could tell me how would you copy a files from a cd rom (not knowing the drive letter) to the system32 directory.

I have created a script to check for the lastest vulnerabilites and disable the wireless connections on notebooks as they enter our facility. The problem is I have 2 files that I need to complete this task.

A .vbs script and .exe. If at all possible I could run the script via referring to the files on the cd, I wouldn't have to worry about copying. Could this be possible? Otherwise I need to copy both files into system32 directory.

I am a newbie and would appreciate any help that you could provide.

Thanks!

If it is the same two files every time you could include them in your compiled script using FileInstall


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

OK that is helpful.

To explaing alittle better on what I am trying to do. The .vbs script references devcon.exe (a Microsoft network tool). Would that be possible with what I am trying to do?

Also, I have tried converting my .vbs script into a .au3 script but having trouble doing so If there was a way to convert it then I could include it within my script. I am running out of time to get this project done.

Thanks!

Link to comment
Share on other sites

Just to elaborate on BigDod's words:

FileInstall() is used to embed files into a compiled AutoIt script. What such a script could then do is extract those files to (e.g.) the running user's temporary folder and execute the files from there.

; Flag files for inclusion at compile time
; Extract them at run time
; First parameter is where to find file when compiling
; Second parameter is where to extract when running

fileInstall("my.vbs", @tempDir & "\my.vbs")
fileInstall("devcon.exe", @tempDir & "\devcon.exe")

runWait(@tempDir & "\devcon.exe", @tempDir)

If you code things this way, you won't need any knowledge of the CD-ROM drive whatsoever in your AutoIt script.

Hope that helps!

Link to comment
Share on other sites

I was wondering if you could tell me how would you copy a files from a cd rom (not knowing the drive letter) to the system32 directory.

If you have your script on the HDD then you could just use a function to find the CD as shown:

; Example use
$result = _FindCD("setup.exe", 0)
MsgBox(0, "", $result)

Func _FindCD($name, $option)
  ; e.g. _FindCD('Setup.exe', 0) or _FindCD('CD Title', 1)
  ; $option: 0 = Filename in CD Root; 1 = CD title
    Local $allocated, $drives
    While Not $allocated
        $drives = DriveGetDrive('CDROM')
        If Not @error Then
            For $i = 1 To $drives[0]
                If DriveStatus($drives[$i] & '\') = 'READY' Then
                    If $option = 0 Then
                        If FileExists($drives[$i] & '\' & $name) Then
                            $allocated = $drives[$i]
                            Return $allocated
                        EndIf
                    ElseIf $option = 1 Then
                        $allocated = $drives[$i]
                        If DriveGetLabel($allocated) = $name Then
                            Return $allocated
                        EndIf
                    EndIf
                EndIf
            Next
            If Not $allocated Then
                If MsgBox(5 + 16, 'Warning', 'Please insert CD into a drive now') = 2 Then
                    Sleep(1000)
                    If MsgBox(4 + 32, 'Important', 'Are you sure that you want to exit') = 6 Then Exit
                EndIf
                Sleep(2000)
            EndIf
        EndIf
    WEnd
EndFunc

If you execute the scipt from the CD then you just need to use the @ScriptDir macro and use relative paths to the files. Or FileInstall as already mentioned.

Edit: You may need to run Tidy on the code to get the indenting back.

Edited by MHz
Link to comment
Share on other sites

; Flag files for inclusion at compile time
; Extract them at run time
; First parameter is where to find file when compiling
; Second parameter is where to extract when running

fileInstall("my.vbs", @tempDir & "\my.vbs")
fileInstall("devcon.exe", @tempDir & "\devcon.exe")

runWait(@tempDir & "\devcon.exe", @tempDir)

If you code things this way, you won't need any knowledge of the CD-ROM drive whatsoever in your AutoIt script.

Hope that helps!

I finally got my.vbs to work and even off the CD-ROM. But I had to play with it a bit to get it to work. It is really close to what you suggested. Here is what I am using:

; This Script will perform Disable ALL Wireless Connections

fileInstall("DisableWireless.vbs", @tempDir & "\disablewireless.vbs")
fileInstall("devcon.exe", @tempDir & "\devcon.exe")
RunWait('wscript.exe "c:\temp\disablewireless.vbs"')

Thanks again for all your help!

;)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...