home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 December / Chip_2001-12_cd2.bin / utilities / iomega / ready_to_move.exe / SystemFiles / autoZip.run < prev    next >
Text File  |  2001-10-03  |  5KB  |  191 lines

  1. // ScriptId "XP Migration tool" "{5416BF74-BB3D-4a7a-8C0A-E88C8EF79B5D}"
  2. // Language "JScript"
  3. // Version 1.0
  4.  
  5. ////////////////////////////////////////////////////////////////////
  6. //  MSS 9/27
  7. //
  8. //    This script will run the Microsoft Migration Wizard to aid
  9. //    in the migration process to XP.
  10. //
  11. ////////////////////////////////////////////////////////////////////
  12.  
  13.  
  14. // Global Variables
  15. var ActiveDiskObj;    // global custom application
  16. var AppIndex;
  17. var drv;
  18. var WshShellObj, fso;
  19. var ShowSplash;
  20.  
  21. function OnInsert( drvLetter ) {
  22.     var MsgString;
  23.     var RegSpanPath;
  24.     var f, Source, Dest, DestFolder;
  25.     
  26.     drv = drvLetter;
  27.  
  28.   try
  29.   {
  30.     // Create a Shell Object 
  31.     WshShellObj = new ActiveXObject( "WScript.Shell");
  32.     // Create the Active Disk Object and initalize it
  33.     ActiveDiskObj = new ActiveXObject("AutoLib.AutoCust");
  34.     ActiveDiskObj.InitDriveLetter(drvLetter);
  35.     // Create the File System object
  36.     fso = new ActiveXObject("Scripting.FileSystemObject");
  37.   }
  38.   catch ( err )
  39.   {
  40.     if (WshShellObj == null)
  41.     {
  42.         // Can't display error message so just exit
  43.         return false;
  44.     }
  45.     if(ActiveDiskObj == null)
  46.     {
  47.         MsgString = "ActiveDisk object is null";
  48.     }
  49.     if(ActiveDiskObj == null)
  50.     {
  51.         MsgString = "FileSystem object is null";
  52.     }
  53.     WshShellObj.Popup(MsgString);
  54.     return false;
  55.   }
  56.  
  57.   try
  58.   {
  59.     // Look to see if we should show the splash screen now before we create the file
  60.     if( fso.FileExists(drv+":\\Usmt2img.dat") ){
  61.         ShowSplash = 1;
  62.     }
  63.     else {
  64.         ShowSplash = 0;
  65.     }
  66.     // Create temporary folder if it doen't already exist
  67.     DestFolder = "c:\\migrate";
  68.     if (!fso.FolderExists(DestFolder))
  69.     {         
  70.         fso.CreateFolder(DestFolder);
  71.     }
  72.     // copy ADSplash to the same temorary spot
  73.     Dest = DestFolder + "\\ADSplash.exe";
  74.     Source = drvLetter + ":\\ADSplash.exe";
  75.     CopyUpdateFile(Source, Dest, true);
  76.     //copy Fastwiz to a temporary spot on the hard disk
  77.     Source = drvLetter + ":\\fastwiz.exe";
  78.     Dest = DestFolder + "\\fastwiz.exe";
  79.     CopyUpdateFile(Source, Dest, true);
  80.   }
  81.   catch (err)
  82.   {
  83.     MsgString = "Temp file could not be copied";
  84.     WshShellObj.Popup(MsgString);
  85.     return false;
  86.   }
  87.  
  88.   try
  89.   {    
  90.     // set the registry for spanning
  91.     RegSpanPath = "HKLM\\Software\\Iomega Corp\\ActivityDisks\\CurrentVersion\\" + drvLetter + "\\Spanning" ;
  92.     WshShellObj.RegWrite (RegSpanPath,1,"REG_DWORD");
  93.     // run the Wizard
  94.     AppIndex = ActiveDiskObj.StartApp( Dest,    //app to run
  95.                     "",        // cmd line arg
  96.                     "c:\\migrate",    // working directory
  97.                     2,        // 2 = Show_Normal
  98.                     true,        // Wait for app to finish
  99.                     0,        // Time out is infinite
  100.                     true,        // Close on eject
  101.                     true,        // Force shutdown
  102.                     0);        // infinte wait for shutdown
  103.   }
  104.   catch (err)
  105.   {
  106.     MsgString = "Can't launch application.";
  107.     WshShellObj.Popup(MsgString);
  108.     return false;
  109.   }
  110.        
  111.     // turn off spanning
  112.     WshShellObj.RegWrite (RegSpanPath,0,"REG_DWORD");
  113.  
  114.     return true;
  115.  
  116. } // end of OnInsert
  117.  
  118.  
  119. //**********************************************************************************
  120. //**     OnEject()
  121. //**                   This function is called when the eject button is pressed
  122. //**********************************************************************************
  123. function OnEject() {
  124.     var Splash;
  125.  
  126.     if( ShowSplash ){ //if the file is there then...
  127.         Splash = ActiveDiskObj.StartApp( "c:\\migrate\\ADSplash.exe",    //app to run
  128.                         "/i",        // cmd line arg
  129.                         "c:\\migrate",    // working directory
  130.                         2,        // 2 = Show_Normal
  131.                         true,        // Wait for app to finish
  132.                         8,        // Time out is infinite
  133.                         false,        // Close on eject
  134.                         true,        // Force shutdown
  135.                         0);        // infinte wait for shutdown
  136.         }
  137.     ActiveDiskObj.ShutdownApplication(AppIndex, true, true, 0);
  138.     if( ShowSplash ){ //if the file is there then...
  139.         ActiveDiskObj.ShutdownApplication(Splash, true, true, 0);
  140.     }
  141. }
  142.  
  143.  
  144. //Private functions for this script
  145.  
  146. //**********************************************************************************
  147. //**     CopyUpdateFile
  148. //**                   This function will Copy over a file or update a file
  149. //**********************************************************************************
  150. function CopyUpdateFile( SourcePath, DestinationPath, Logit ){
  151.  
  152.     var        SourceObj;
  153.     var        DestObj;
  154.     var        SourceVer;
  155.     var        DestVer;
  156.  
  157.   try{
  158.     if( fso.FileExists(DestinationPath) ){ //if the file is there then...
  159.         Logit = false;
  160.         SourceVer = fso.GetFileVersion( SourcePath );  // get the file version
  161.         DestVer = fso.GetFileVersion( DestinationPath );
  162.         if( DestVer != "" && SourceVer != "" ) {  // we have version information
  163.             if( DestVer >= SourceVer){ // then do not copy
  164.                 return true;
  165.             }
  166.         } else { // in this case then lets check the date 
  167.             SourceObj = fso.GetFile(    SourcePath );
  168.             DestObj = fso.GetFile( DestinationPath );
  169.             if( DestObj.DateLastModified >=    SourceObj.DateLastModified ){ // then do not copy
  170.                 return true;
  171.             }
  172.         }
  173.     }
  174.     // Remove any read only attr
  175.     if( fso.FileExists(DestinationPath) ){ //if the file is there then...
  176.         DestObj = fso.GetFile( DestinationPath );
  177.         if( (DestObj.attributes & 1) == 1) { // is it read only
  178.             DestObj.attributes = DestObj.attributes - 1;
  179.         }    
  180.     }
  181.      fso.CopyFile(SourcePath,DestinationPath,true); // copy over the file
  182.     if(    Logit == true ){  // then log the file
  183.         ActivityObj.LogTempFile(DestinationPath);
  184.     }
  185.   }
  186.   catch(err){
  187.         return false;
  188.   }
  189.     return true;
  190. }
  191.