Sign in to follow this  
Followers 0
DaLiMan

copy to cd

31 posts in this topic

Hi,

I'm trying to make this script which copies all the files from some directories to a CD. [for back-up]

But the problem is getting these files on the disc.

I have no idea on how to do that.

Anyone any ideas?

BTW how can I open explorer.exe in C:\ or D:\ or E:\ from auto-it?[wich ever I prefer]

I was thinking:

Run("explorer.exe", "E:\", @SW_MAXIMIZE)

but this don't work.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Run("explorer.exe e:\", "e:\", @SW_MAXIMIZE)

you need software to "Burn" files onto a CD. Many CD writers come with it. If you can drag files and drop them then you are already golden.

I don't know the names of most of the programs (hundreds) but most have you initialise the disk in some way and then once done it acts like a hard drive. You can then use any of autoit's file functions to copy or move files to that CD.

Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

DirCopy

--------------------------------------------------------------------------------

Copies a directory and all sub-directories and files (Similar to xcopy).

DirCopy ( "source dir", "dest dir" [, flag])

Parameters

source dir Path of the source directory (with no trailing backslash). eg. "C:\Path1"

dest dir Path of the destination dir (with no trailing backslash). eg. "C:\Path_Copy"

flag [optional] this flag determines whether to overwrite file if they already exist:

0 = (default) do not overwrite existing files

1 = overwrite existing files

Example:

DirCopy("C:\My Documents", "C:\Backups\MyDocs", 1)
Edited by BL@(K-R34P3R

Share this post


Link to post
Share on other sites

>>I'm trying to make this script which copies all the files from some directories to a CD. [for back-up]

FileCopy, DirCopy if CD is formatted

>>BTW how can I open explorer.exe in C:\ or D:\ or E:\ from auto-it?[wich ever I prefer]

Run("explorer.exe e:" , "" , @SW_MAXIMIZE )

Share this post


Link to post
Share on other sites

Too funny, 40 min after 3 people type simultaneously. :)


AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

I have just completed a project that is exactly what you require I think.

I have used all freeware command line tools, specifically MFISOFS to create a .ISO file of the required directories, and then FILE2CD to write the .ISO to the CD recorder.

MKISOFS is available here

FILE2CD is part of the DOS version of CDRWIN. The FILE2CD component is freeware. It is available here.

RunWait(@ComSpec & " /c " & "mkisofs.exe -graft-points -o " & @TempDir & "\temp.iso -R -J -v " & '"Calendar Files=' & $SOURCE & '" "' & @ScriptDir & '"' )
RunWait(@ComSpec & " /c " & "File2CD.exe " & @TempDir & "\temp.iso /id=" & $DEVICEID & "  /noconfirm /eject" )

FileDelete(@TempDir & "\temp.iso")

My specific solution uses an .ini file to record the directories to add to the .ISO, and to specify the device id of the CD recorder.

Hope this helps. Plenty of command line options for MKISOFS available online.

Cheers

Monster

Share this post


Link to post
Share on other sites

Discussed many times...

Check here.

Share this post


Link to post
Share on other sites

>>BTW how can I open explorer.exe in C:\ or D:\ or E:\ from auto-it?[wich ever I prefer]

Run("explorer.exe e:" , "" , @SW_MAXIMIZE )

<{POST_SNAPBACK}>

Actually is:

$letter = 'e:'
Run("explorer.exe /e," & $letter , "" , @SW_MAXIMIZE )

Share this post


Link to post
Share on other sites

cdrecord is another commandline tool for writing ISOs to disc.

<{POST_SNAPBACK}>

The advantage of the MKISOFS tool and the other tools provided by the link that m0n5ter provided over CD record and the other tools listed at the post that ezzetabi gave is that they are open source, cross platform, and personal support is still available. I personally DO NOT suggest using cdrecord if you have access to the other tools. Thats one mans opinion...

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

The advantage of the MKISOFS tool and the other tools provided by the link that m0n5ter provided over CD record and the other tools listed at the post that ezzetabi gave is that they are open source, cross platform, and personal support is still available. I personally DO NOT suggest using cdrecord if you have access to the other tools. Thats one mans opinion...

*** Matt @ MPCS

<{POST_SNAPBACK}>

Also the solution I gave is Win9X compatible too, whereas CDRecord and BurnCD are WinNT/XP specific.

All you need to allow Win9X compatibility is an ASPI layer. I used ForceASPI1.7 available here.

Share this post


Link to post
Share on other sites

Also the solution I gave is Win9X compatible too, whereas CDRecord and BurnCD are WinNT/XP specific.

All you need to allow Win9X compatibility is an ASPI layer. I used ForceASPI1.7 available here.

<{POST_SNAPBACK}>

That is very useful, but have you ported the batch scripts that come with the zip to AutoIt yet? If not then I will do so and post them with the drivers. (If I can free up the disk space).

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

If you own Ahead's Nero Burning Rom, BoBo has provided something similar here: Nero-Backup via command line

But, I assume you've meant to work with XP's own context-menu-option "Burn to CD" ? :)

Share this post


Link to post
Share on other sites

I haven't ported the batch files Matt. Never really occured to me to do this. Feel free though. I might find a use for it.

Monster

Share this post


Link to post
Share on other sites

do you think it would be possible to do

DirCopy("C:\Program Files\", "E:\")

?


My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]

Share this post


Link to post
Share on other sites

do you think it would be possible to do

DirCopy("C:\Program Files\", "E:\")

?

<{POST_SNAPBACK}>

This is only possible if you are using a DLA application that will allow direct disk access. On most computers this is not a possibility.

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

I haven't  ported the batch files Matt. Never really occured to me to do this. Feel free though. I might find a use for it.

Monster

<{POST_SNAPBACK}>

Alright well I have finished an initial port of the code. It is not tested because I no longer own a machine that runs a qualifying operating system (Linux is awesome!). I only have enough share space left here to share the executable which includes all of the required driver files, so I will just c&p the code below. I have plans for features of a future port if anyone is interested in using it so let me know what your plans are and I might do some more work on it.

#include "Includes\Registry.au3"

Global $ver=1.7

Select
   Case $CmdLine[0] = 0
      Install()
   Case ($CmdLine[0] = 1)
      If( ($CmdLine[1] = "/I") Or ($CmdLine[1] = "/Install") ) Then
         Install()
      ElseIf( ($CmdLine[1] = "/U") Or ($CmdLine[1] = "/Uninstall") ) Then
         Uninstall()
      Else
         ShowOptions()
      EndIf
   Case Else
      ShowOptions()
EndSelect

Func Install()
   Select
      Case ( @OSVersion = "WIN_NT4" ) Or ( @OSVersion = "WIN_2000" )
         InstallWinNT()
      Case ( @OSVersion = "WIN_95" ) Or ( @OSVersion = "WIN_98" ) Or ( @OSVersion = "WIN_ME" )
         InstallWin9x()
      Case Else
         MsgBox( 16, "Compatibility Error", "The Operating System running on this computer is not compatible with these drivers." )
   EndSelect
EndFunc

Func InstallWin9x()
   
   Dim $retValue 
   
   $retValue = MsgBox( 36, "Install?", "InstASPI " & $ver & @CRLF & @CRLF _
                           & "Windows 9x od ME Detected." & @CRLF _
                           & "Windows is in : " & @WindowsDir & @CRLF & @CRLF _
                           & "Are you sure you want to install the ASPI Layer?" )
   
   If( $retValue = 7 ) Then
      MsgBox( 48, "Cancelled.", "ASPI Layer installation cancelled by user." )
      Exit -1
   EndIf
   
   ProgressOn( "Installing...", "Installing Adaptec ASPI 4.60 (1021)", "Copying WINASPI.DLL..." )
   FileInstall( "Files\Win9x\winaspi.dll", @WindowsDir )
   ProgressSet( 25, "Copying WNASPI32.DLL..." )
   FileInstall( "Files\Win9x\wnaspi32.dll", @SystemDir )
   ProgressSet( 50, "Copying ASPIENUM.VXD..." )
   FileInstall( "Files\Win9x\aspienum.vxd", @SystemDir )
   ProgressSet( 75, "Copying APIX.VXD..." )
   FileInstall( "Files\Win9x\apix.vxd", @SystemDir & "\iosubsys" )
   ProgressSet( 100, "Adding Registry Settings..." )
   RestoreRegistry( "Files\Win9x\win9x.reg" )
   ProgressOff()
   
   $retValue = MsgBox( 36, "Done", "Adaptec ASPI 4.60 (1021) Installed." & @CRLF & "Reboot your PC to make these changes active?" )
   
   If( $retValue = 6 ) Then
      Shutdown(2)
   EndIf

EndFunc

Func InstallWinNT()
   
   Dim $retValue 
   
   $retValue = MsgBox( 36, "Install?", "InstASPI " & $ver & @CRLF & @CRLF _
                           & "Windows NT od 2000 Detected." & @CRLF _
                           & "Windows is in : " & @WindowsDir & @CRLF & @CRLF _
                           & "Are you sure you want to install the ASPI Layer?" )
   
   If( $retValue = 7 ) Then
      MsgBox( 48, "Cancelled.", "ASPI Layer installation cancelled by user." )
      Exit -1
   EndIf
   
   ProgressOn( "Installing...", "Installing Adaptec ASPI 4.60 (1021)", "Copying WINASPI.DLL..." )
   FileInstall( "Files\WinNt\winaspi.dll", @WindowsDir & "\System" )
   ProgressSet( 25, "Copying WOWPOST.EXE..." )
   FileInstall( "Files\WinNt\wowpost.exe", @WindowsDir & "\System" )
   ProgressSet( 50, "Copying WNASPI32.DLL..." )
   FileInstall( "Files\WinNT\wnaspi32.dll", @WindowsDir & "\System" )
   ProgressSet( 75, "Copying ASPI32.sys..." )
   FileInstall( "Files\WinNt\aspi32.sys", @WindowsDir & "\System32\Drivers" )
   ProgressSet( 100, "Adding Registry Settings..." )
   RestoreRegistry( "Files\WinNt\winnt.reg" )
   ProgressOff()
   
   $retValue = MsgBox( 36, "Done", "Adaptec ASPI 4.60 (1021) Installed." & @CRLF & "Reboot your PC to make these changes active?" )
   
   If( $retValue = 6 ) Then
      Shutdown(2)
   EndIf

EndFunc

Func Uninstall()
   Select
      Case ( @OSVersion = "WIN_NT4" ) Or ( @OSVersion = "WIN_2000" )
         UninstallWinNT()
      Case ( @OSVersion = "WIN_95") Or ( @OSVersion = "WIN_98" ) Or ( @OSVersion = "WIN_ME" )
         UninstallWin9x()
      Case Else
         MsgBox( 16, "Compatibility Error", "The Operating System running on this computer is not compatible with these drivers." )
   EndSelect
EndFunc

Func UninstallWin9x()
   
   Dim $retValue 
   
   $retValue = MsgBox( 36, "Uninstall?", "InstASPI " & $ver & @CRLF & @CRLF _
                           & "Windows 9x od ME Detected." & @CRLF _
                           & "Windows is in : " & @WindowsDir & @CRLF & @CRLF _
                           & "Are you sure you want to uninstall the ASPI Layer?" )
   
   If( $retValue = 7 ) Then
      MsgBox( 48, "Cancelled.", "ASPI Layer removal cancelled by user." )
      Exit -1
   EndIf
   
   ProgressOn( "Uninstalling...", "Uninstalling Adaptec ASPI 4.60 (1021)", "Removing WINASPI.DLL..." )
   FileDelete( @SystemDir & "\winaspi.dll" )
   ProgressSet( 33, "Removing WNASPI32.DLL..." )
   FileDelete( @SystemDir & "\wnaspi32.dll" )
   ProgressSet( 66, "Removing ASPIENUM.VXD..." )
   FileDelete( @SystemDir & "\winaspi.dll" )
   ProgressSet( 99, "Removing APIX.VXD..." )
   FileDelete( @SystemDir & "\iosubsys\winaspi.dll" )
   ProgressOff()
   
   $retValue = MsgBox( 36, "Done", "Adaptec ASPI 4.60 (1021) Uninstalled." & @CRLF & "Reboot your PC to make these changes active?" )
   
   If( $retValue = 6 ) Then
      Shutdown(2)
   EndIf

EndFunc

Func UninstallWinNT()
   
   Dim $retValue 
   
   $retValue = MsgBox( 36, "Uninstall?", "InstASPI " & $ver & @CRLF & @CRLF _
                           & "Windows NT od 2000 Detected." & @CRLF _
                           & "Windows is in : " & @WindowsDir & @CRLF & @CRLF _
                           & "Are you sure you want to uninstall the ASPI Layer?" )
   
   If( $retValue = 7 ) Then
      MsgBox( 48, "Cancelled.", "ASPI Layer removal cancelled by user." )
      Exit -1
   EndIf
   
   ProgressOn( "Uninstalling...", "Uninstalling Adaptec ASPI 4.60 (1021)", "Removing WINASPI.DLL..." )
   FileDelete( @WindowsDir & "\System\winaspi.dll" )
   ProgressSet( 33, "Removing WOWPOST.EXE..." )
   FileDelete( @WindowsDir & "\System\wowpost.exe" )
   ProgressSet( 66, "Removing WNASPI32.DLL..." )
   FileDelete( @WindowsDir & "\System\wnaspi.dll" )
   ProgressSet( 99, "Removing ASPI32.sys..." )
   FileDelete( @WindowsDir & "\System32\Drivers\aspi32.sys" )
   ProgressOff()
   
   $retValue = MsgBox( 36, "Done", "Adaptec ASPI 4.60 (1021) Uninstalled." & @CRLF & "Reboot your PC to make these changes active?" )
   
   If( $retValue = 6 ) Then
      Shutdown(2)
   EndIf

EndFunc

Func ShowOptions()
   MsgBox( 64, "Adaptec ASPI 4.60 (1021)", "USAGE: aspi17 [/i | /install] [/u | /uninstall]" )
EndFunc

Hope this helps someone somewhere!

*** Matt @ MPCS

Edited by Matt @ MPCS

Share this post


Link to post
Share on other sites

#include "Includes\Registry.au3"
Looks good, but where is the file Registry.au3 ???

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

Looks good, but where is the file Registry.au3  ???

<{POST_SNAPBACK}>

My fault... thats what I get for writing my own include files... here is the source for Registry.au3:

#comments-start
********************************************************************
AutoIt Information
-----------------------------------------------------------------------------------------------
   AutoIt Version:   3.0
   Language:         English
   Platform:         Win9x/NT

=====================================================
Script Information
-----------------------------------------------------------------------------------------------
   Name:             Registry.au3
   Author:           Matthew Babcock (IPS)
   Date:             08/15/2004
   
   Purpose:
      Contains functions used for backing up and restoring the system registry.

=====================================================
Function Directory
-----------------------------------------------------------------------------------------------
   BackupRegistry()    ; Generates three-step system registry backup history (RegBackI.reg, RegBackII.reg, RegBackIII.reg)
   RestoreRegistry()  ; Restores system registry 

=====================================================
Change Log
-----------------------------------------------------------------------------------------------
   08/15/2004: Created Registry.au3
               Created function BackupRegistry v.5a
               Created function RestoreRegistry v.5a
   
********************************************************************
#comments-end

#include <Process.au3>

Func BackupRegistry( $BackupDir )
;*******************************************************************
;  Name:    BackupRegistry
;  Author:  Matthew Babcock (IPS)
;  Date:    08/25/2004
;
;  Parameters:
;     None
;
;  Returns:
;     An integer of 0 if successful or -1 if failure.
;
;  Notes:
;     Generates three-step backup history, RegBackI.reg - RegBackIII.reg
;*******************************************************************

  ; Verify the accepted backup directory exists
   If FileExists( $BackupDir ) Then
      If( StringRight( $BackupDir, 1 ) <> "\" ) Then $BackupDir = $BackupDir & "\"
   Else
      DirCreate( @DesktopCommonDir & "\Registry Backup" )
      $BackupDir = @DesktopCommonDir & "\Registry Backup"
   EndIf
   
  ; Delete third backup
   if FileExists($BackupDir & "\RegBackIII.reg") Then
      FileDelete($BackupDir & "\RegBackIII.reg")
   EndIf
   
  ; Rename second to third backup
   If FileExists($BackupDir & "\RegBackII.reg") Then
      FileCopy($BackupDir & "\RegBackII.reg", $BackupDir & "\RegBackIII.reg")
   EndIf
   
  ; Rename first to second backup
   if FileExists($BackupDir & "\RegBackI.reg") Then
      FileCopy($BackupDir & "\RegBackI.reg", $BackupDir & "\RegBackII.reg")
   EndIf
   
  ; Create first backup file
   _RunDOS("regedit /e " & $BackupDir & "\RegBackI.reg")

   Return 0

EndFunc

Func RestoreRegistry( $RestoreFile )
;*******************************************************************
;  Name:    BackupRegistry
;  Author:  Matthew Babcock (IPS)
;  Date:    08/25/2004
;
;  Parameters:
;     $RestoreFile - The full path of the file to restore
;
;  Returns:
;     An integer of 0 if successful or -1 if failure.
;
;  Notes:
;     None
;*******************************************************************
   
   If ( FileExists( $RestoreFile ) ) Then
      _RunDOS( "regedit /s " & $RestoreFile )
   Else
      MsgBox( 16, "Restore Failed", "The file " & $RestoreFile & " does not exist. System registry restoration failed." )
      Return -1
   EndIf

   Return 0

EndFunc
Edited by Matt @ MPCS

Share this post


Link to post
Share on other sites

My fault... thats what I get for writing my own include files... here is the source for Registry.au3:

#comments-start
****************************************************************************************************

**********************************
AutoIt Information
--------------------------------------------------------------------------------------------------------------------------------------
   AutoIt Version:   3.0
   Language:         English
   Platform:         Win9x/NT

====================================================================================================

==================================
Script Information
--------------------------------------------------------------------------------------------------------------------------------------
   Name:             Registry.au3
   Author:           Matthew Babcock (IPS)
   Date:             08/15/2004
   
   Purpose:
      Contains functions used for backing up and restoring the system registry.

====================================================================================================

==================================
Function Directory
--------------------------------------------------------------------------------------------------------------------------------------
   BackupRegistry()    ; Generates three-step system registry backup history (RegBackI.reg, RegBackII.reg, RegBackIII.reg)
   RestoreRegistry()  ; Restores system registry 

====================================================================================================

==================================
Change Log
--------------------------------------------------------------------------------------------------------------------------------------
   08/15/2004: Created Registry.au3
               Created function BackupRegistry v.5a
               Created function RestoreRegistry v.5a
   
****************************************************************************************************

**********************************
#comments-end

#include <Process.au3>

Func BackupRegistry( $BackupDir )
;***************************************************************************************************

**********************************
;  Name:    BackupRegistry
;  Author:  Matthew Babcock (IPS)
;  Date:    08/25/2004
;
;  Parameters:
;     None
;
;  Returns:
;     An integer of 0 if successful or -1 if failure.
;
;  Notes:
;     Generates three-step backup history, RegBackI.reg - RegBackIII.reg
;***************************************************************************************************

**********************************

  ; Verify the accepted backup directory exists
   If FileExists( $BackupDir ) Then
      If( StringRight( $BackupDir, 1 ) <> "\" ) Then $BackupDir = $BackupDir & "\"
   Else
      DirCreate( @DesktopCommonDir & "\Registry Backup" )
      $BackupDir = @DesktopCommonDir & "\Registry Backup"
   EndIf
   
  ; Delete third backup
   if FileExists($BackupDir & "\RegBackIII.reg") Then
      FileDelete($BackupDir & "\RegBackIII.reg")
   EndIf
   
  ; Rename second to third backup
   If FileExists($BackupDir & "\RegBackII.reg") Then
      FileCopy($BackupDir & "\RegBackII.reg", $BackupDir & "\RegBackIII.reg")
   EndIf
   
  ; Rename first to second backup
   if FileExists($BackupDir & "\RegBackI.reg") Then
      FileCopy($BackupDir & "\RegBackI.reg", $BackupDir & "\RegBackII.reg")
   EndIf
   
  ; Create first backup file
   _RunDOS("regedit /e " & $BackupDir & "\RegBackI.reg")

   Return 0

EndFunc

Func RestoreRegistry( $RestoreFile )
;***************************************************************************************************

**********************************
;  Name:    BackupRegistry
;  Author:  Matthew Babcock (IPS)
;  Date:    08/25/2004
;
;  Parameters:
;     $RestoreFile - The full path of the file to restore
;
;  Returns:
;     An integer of 0 if successful or -1 if failure.
;
;  Notes:
;     None
;***************************************************************************************************

**********************************
   
   If ( FileExists( $RestoreFile ) ) Then
      _RunDOS( "regedit /s " & $RestoreFile )
   Else
      MsgBox( 16, "Restore Failed", "The file " & $RestoreFile & " does not exist. System registry restoration failed." )
      Return -1
   EndIf

   Return 0

EndFunc

<{POST_SNAPBACK}>

3 Problems:

1. Need to add :) Or ( @OSVersion = "WIN_XP" ) to allow it to work on XP

2: Typo :) "Windows 9x od ME Detected." & @CRLF

3: Your asterisks in your comments in registry.au3 are wrapped on the message board, and need trimmed before executing due to a parsing error if you copy, paste and save it.

Otherwise looks good.

Cheers

Monster

Share this post


Link to post
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
Sign in to follow this  
Followers 0