Advertisement
Guest User

ISO Extractor

a guest
Jun 16th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>ISO Extractor</title>
  5.  
  6. <HTA:APPLICATION
  7.   APPLICATIONNAME="ISO Extractor"
  8.   ID="ISOExtractor"
  9.   VERSION="1.0"
  10.   SCROLL="no"/>
  11.  
  12. <style type="text/css">
  13. body {
  14.     background-color: #fdfeff;
  15.     color: darkblue;
  16.     font-family: Calibri;
  17.     font-size: 12pt;
  18.     margin: 1em 1em;
  19. }
  20. </style>
  21. </head>
  22.  
  23. <script language="VBScript">
  24. Option Explicit
  25.  
  26. Sub Window_OnLoad
  27.     window.resizeTo 480, 240
  28.     document.title = document.title & ",  Version " & ISOExtractor.Version
  29. End Sub
  30.  
  31. Sub SelectISOFile( )
  32.     ' File Browser via HTA
  33.    ' Author:   Rudi Degrande, modifications by Denis St-Pierre and Rob van der Woude
  34.    ' Features: Works in Windows Vista and up (Should also work in XP).
  35.    '           Fairly fast.
  36.    '           All native code/controls (No 3rd party DLL/ XP DLL).
  37.    ' Caveats:  Cannot define default starting folder.
  38.    '           Uses last folder used with MSHTA.EXE stored in Binary in [HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32].
  39.    '           Dialog title says "Choose file to upload".
  40.    ' Source:   https://social.technet.microsoft.com/Forums/scriptcenter/en-US/a3b358e8-15ae-4ba3-bca5-ec349df65ef6/windows7-vbscript-open-file-dialog-box-fakepath?forum=ITCG
  41.  
  42.     Dim objExec, strMSHTA, wshShell
  43.  
  44.     'SelectISOFile = ""
  45.  
  46.     ' For use in HTAs as well as "plain" VBScript:
  47.    strMSHTA = "mshta.exe ""about:" & "<" & "input type=file id=FILE>" _
  48.              & "<" & "script>FILE.click();new ActiveXObject('Scripting.FileSystemObject')" _
  49.              & ".GetStandardStream(1).WriteLine(FILE.value);close();resizeTo(0,0);" & "<" & "/script>"""
  50.  
  51.     Set wshShell = CreateObject( "WScript.Shell" )
  52.     Set objExec = wshShell.Exec( strMSHTA )
  53.  
  54.     document.getElementById( "SourceISOPathTxtBox" ).value = objExec.StdOut.ReadLine( )
  55.  
  56.     Set objExec = Nothing
  57.     Set wshShell = Nothing
  58. End Sub
  59.  
  60. Sub SelectFolder( ) ' myStartFolder )
  61. ' This function opens a "Select Folder" dialog and will
  62. ' return the fully qualified path of the selected folder
  63. '
  64. ' Argument:
  65. '     myStartFolder    [string]    the root folder where you can start browsing;
  66. '                                  if an empty string is used, browsing starts
  67. '                                  on the local computer
  68. '
  69. ' Returns:
  70. ' A string containing the fully qualified path of the selected folder
  71. '
  72. ' Written by Rob van der Woude
  73. ' http://www.robvanderwoude.com
  74.  
  75.     ' Standard housekeeping
  76.    Dim objFolder, objItem, objShell, myStartFolder
  77.    
  78.     ' Custom error handling
  79.    On Error Resume Next
  80.     'SelectFolder = vbNull
  81.     myStartFolder = "D:\"
  82.    
  83.     ' Create a dialog object
  84.    Set objShell  = CreateObject( "Shell.Application" )
  85.     Set objFolder = objShell.BrowseForFolder( 0, "Select Folder", 0, myStartFolder )
  86.  
  87.     ' Return the path of the selected folder
  88.    If IsObject( objfolder ) Then document.getElementById( "ExtractDestinationFolderTxtBox" ).value = objFolder.Self.Path
  89.  
  90.     ' Standard housekeeping
  91.    Set objFolder = Nothing
  92.     Set objshell  = Nothing
  93.     On Error Goto 0
  94. End Sub
  95.  
  96. Sub DeleteFolderContents( )
  97.     Dim fso, folder
  98.     Set fso = CreateObject("Scripting.FileSystemObject")
  99.     Set folder = fso.GetFolder(document.getElementById( "ExtractDestinationFolderTxtBox" ).value)
  100.    
  101.     ' delete all files in root folder
  102.     Dim f
  103.     For each f in folder.Files
  104.         On Error Resume Next
  105.         Dim name
  106.         name = f.name
  107.         f.Delete True
  108.         If Err Then
  109.             window.Alert "Error deleting: " & name & " - " & Err.Description
  110.             document.getElementById( "SourceISOPathTxtBox" ).value = "false"
  111.         Else
  112.             'WScript.Echo "Deleted:" & name
  113.         End If
  114.         On Error GoTo 0
  115.     Next
  116.  
  117.     ' delete all subfolders and files
  118.     For Each f In folder.SubFolders
  119.         On Error Resume Next
  120.         name = f.name
  121.         f.Delete True
  122.         If Err Then
  123.             window.Alert "Error deleting: " & name & " - " & Err.Description
  124.             document.getElementById( "SourceISOPathTxtBox" ).value = "false"
  125.         Else
  126.             'WScript.Echo "Deleted:" & name
  127.         End If
  128.         On Error GoTo 0
  129.     Next
  130. End Sub
  131.  
  132. Sub ExtractISO( )
  133.  
  134.     Dim objShell', returnValue
  135.     const DontWaitUntilFinished = false, ShowWindow = 1, DontShowWindow = 0, WaitUntilFinished = true
  136.     Set objShell = CreateObject("WScript.Shell")
  137.    
  138.     Dim WinRARPath, ISOPath, DestinationFolder
  139.     WinRARPath = Chr(34) & "C:\Program Files\WinRar\WinRar.exe" & Chr(34)
  140.     ISOPath = Chr(34) & SourceISOPathTxtBoxValue & Chr(34)
  141.     DestinationFolder = Chr(34) & ExtractDestinationFolderTxtBoxValue & Chr(34)
  142.    
  143.     document.getElementById( "WinRARExitCode" ).value = objShell.Run(WinRARPath & " X " &  ISOPath & " " & DestinationFolder, DontShowWindow, WaitUntilFinished)
  144.     Set objShell = Nothing
  145.    
  146. End Sub
  147.  
  148. Sub ExtractISOButton( )
  149.     If document.getElementById("CleanDestinationFirst").checked = true Then
  150.         Call DeleteFolderContents
  151.     End If
  152.     If document.getElementById( "isDeleteFolderContentsSuccessful" ).value = "true" Then
  153.         Call ExtractISO
  154.        
  155.         'If document.getElementById( "isISOExtractionSuccessful" ).value = "true" Then
  156.             document.getElementById( "OutputResult" ).innerHTML = "Extraction Result: " & WinRARExitCodeToString(document.getElementById( "WinRARExitCode" ).value)
  157.         'Else
  158.         '   document.getElementById( "OutputResult" ).innerHTML = "ISO file extraction failed."
  159.         'End If
  160.     Else
  161.         document.getElementById( "OutputResult" ).innerHTML = "An error occurred while cleaning the destination folder. ISO extraction has been cancelled."
  162.     End If
  163.    
  164. End Sub
  165.  
  166. Sub Reset( )
  167.     document.getElementById( "WinRARExitCode" ).value = ""
  168.     document.getElementById( "isDeleteFolderContentsSuccessful" ).value = ""
  169.    
  170. End Sub
  171.  
  172. Function SourceISOPathTxtBoxValue()
  173.     SourceISOPathTxtBoxValue = document.getElementById( "SourceISOPathTxtBox" ).value
  174. End Function
  175.  
  176. Function ExtractDestinationFolderTxtBoxValue()
  177.     ExtractDestinationFolderTxtBoxValue = document.getElementById( "ExtractDestinationFolderTxtBox" ).value
  178. End Function
  179.  
  180. Function WinRARExitCodeToString(ExitCode)
  181.     Dim ExitCodeDescription
  182.    
  183.     Select Case ExitCode
  184.         Case "0"
  185.             ExitCodeDescription = " Successful operation."
  186.         Case "1"
  187.             ExitCodeDescription = " Warning. Non fatal error(s) occurred."
  188.         Case "2"
  189.             ExitCodeDescription = " A fatal error occurred."
  190.         Case "3"
  191.             ExitCodeDescription = " Invalid checksum. Data is damaged."
  192.         Case "4"
  193.             ExitCodeDescription = " Attempt to modify a locked archive."
  194.         Case "5"
  195.             ExitCodeDescription = " Write error."
  196.         Case "6"
  197.             ExitCodeDescription = " File open error."
  198.         Case "7"
  199.             ExitCodeDescription = " Wrong command line option."
  200.         Case "8"
  201.             ExitCodeDescription = " Not enough memory."
  202.         Case "9"
  203.             ExitCodeDescription = " File create error."
  204.         Case "10"
  205.             ExitCodeDescription = " No files matching the specified mask and options were found."
  206.         Case "11"
  207.             ExitCodeDescription = " Wrong password."
  208.         Case "255"
  209.             ExitCodeDescription = " User break."
  210.        
  211.     End Select
  212.     WinRARExitCodeToString = ExitCodeDescription
  213.    
  214. End Function
  215. </script>
  216.  
  217. <body>
  218.  
  219. <p align="center"><input type="text" id="SourceISOPathTxtBox" style="width:235px" />
  220. &nbsp;
  221. <input type="button" value="Select ISO File..." style="width:175px" onclick="SelectISOFile" /></p>
  222.  
  223. <p align="center"><input type="text" id="ExtractDestinationFolderTxtBox" style="width:235px" />
  224. &nbsp;
  225. <input type="button" value="Select Extraction Folder..." style="width:175px" onclick="SelectFolder" /></p>
  226.  
  227. <p align="center"><input type="checkbox" id="CleanDestinationFirst" checked>Clean Extract Folder Before Extraction</></p>
  228.  
  229. <p align="center"><input type="button" value="Extract ISO" style="width:175px" onclick="ExtractISOButton" /></p>
  230.  
  231. <input type="hidden" id="isDeleteFolderContentsSuccessful" value="true">
  232. <input type="hidden" id="WinRARExitCode" value="">
  233. <p id="OutputResult"></p>
  234.  
  235. </body>
  236. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement