Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html>
- <head>
- <title>ISO Extractor</title>
- <HTA:APPLICATION
- APPLICATIONNAME="ISO Extractor"
- ID="ISOExtractor"
- VERSION="1.0"
- SCROLL="no"/>
- <style type="text/css">
- body {
- background-color: #fdfeff;
- color: darkblue;
- font-family: Calibri;
- font-size: 12pt;
- margin: 1em 1em;
- }
- </style>
- </head>
- <script language="VBScript">
- Option Explicit
- Sub Window_OnLoad
- window.resizeTo 480, 240
- document.title = document.title & ", Version " & ISOExtractor.Version
- End Sub
- Sub SelectISOFile( )
- ' File Browser via HTA
- ' Author: Rudi Degrande, modifications by Denis St-Pierre and Rob van der Woude
- ' Features: Works in Windows Vista and up (Should also work in XP).
- ' Fairly fast.
- ' All native code/controls (No 3rd party DLL/ XP DLL).
- ' Caveats: Cannot define default starting folder.
- ' Uses last folder used with MSHTA.EXE stored in Binary in [HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32].
- ' Dialog title says "Choose file to upload".
- ' Source: https://social.technet.microsoft.com/Forums/scriptcenter/en-US/a3b358e8-15ae-4ba3-bca5-ec349df65ef6/windows7-vbscript-open-file-dialog-box-fakepath?forum=ITCG
- Dim objExec, strMSHTA, wshShell
- 'SelectISOFile = ""
- ' For use in HTAs as well as "plain" VBScript:
- strMSHTA = "mshta.exe ""about:" & "<" & "input type=file id=FILE>" _
- & "<" & "script>FILE.click();new ActiveXObject('Scripting.FileSystemObject')" _
- & ".GetStandardStream(1).WriteLine(FILE.value);close();resizeTo(0,0);" & "<" & "/script>"""
- Set wshShell = CreateObject( "WScript.Shell" )
- Set objExec = wshShell.Exec( strMSHTA )
- document.getElementById( "SourceISOPathTxtBox" ).value = objExec.StdOut.ReadLine( )
- Set objExec = Nothing
- Set wshShell = Nothing
- End Sub
- Sub SelectFolder( ) ' myStartFolder )
- ' This function opens a "Select Folder" dialog and will
- ' return the fully qualified path of the selected folder
- '
- ' Argument:
- ' myStartFolder [string] the root folder where you can start browsing;
- ' if an empty string is used, browsing starts
- ' on the local computer
- '
- ' Returns:
- ' A string containing the fully qualified path of the selected folder
- '
- ' Written by Rob van der Woude
- ' http://www.robvanderwoude.com
- ' Standard housekeeping
- Dim objFolder, objItem, objShell, myStartFolder
- ' Custom error handling
- On Error Resume Next
- 'SelectFolder = vbNull
- myStartFolder = "D:\"
- ' Create a dialog object
- Set objShell = CreateObject( "Shell.Application" )
- Set objFolder = objShell.BrowseForFolder( 0, "Select Folder", 0, myStartFolder )
- ' Return the path of the selected folder
- If IsObject( objfolder ) Then document.getElementById( "ExtractDestinationFolderTxtBox" ).value = objFolder.Self.Path
- ' Standard housekeeping
- Set objFolder = Nothing
- Set objshell = Nothing
- On Error Goto 0
- End Sub
- Sub DeleteFolderContents( )
- Dim fso, folder
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set folder = fso.GetFolder(document.getElementById( "ExtractDestinationFolderTxtBox" ).value)
- ' delete all files in root folder
- Dim f
- For each f in folder.Files
- On Error Resume Next
- Dim name
- name = f.name
- f.Delete True
- If Err Then
- window.Alert "Error deleting: " & name & " - " & Err.Description
- document.getElementById( "SourceISOPathTxtBox" ).value = "false"
- Else
- 'WScript.Echo "Deleted:" & name
- End If
- On Error GoTo 0
- Next
- ' delete all subfolders and files
- For Each f In folder.SubFolders
- On Error Resume Next
- name = f.name
- f.Delete True
- If Err Then
- window.Alert "Error deleting: " & name & " - " & Err.Description
- document.getElementById( "SourceISOPathTxtBox" ).value = "false"
- Else
- 'WScript.Echo "Deleted:" & name
- End If
- On Error GoTo 0
- Next
- End Sub
- Sub ExtractISO( )
- Dim objShell', returnValue
- const DontWaitUntilFinished = false, ShowWindow = 1, DontShowWindow = 0, WaitUntilFinished = true
- Set objShell = CreateObject("WScript.Shell")
- Dim WinRARPath, ISOPath, DestinationFolder
- WinRARPath = Chr(34) & "C:\Program Files\WinRar\WinRar.exe" & Chr(34)
- ISOPath = Chr(34) & SourceISOPathTxtBoxValue & Chr(34)
- DestinationFolder = Chr(34) & ExtractDestinationFolderTxtBoxValue & Chr(34)
- document.getElementById( "WinRARExitCode" ).value = objShell.Run(WinRARPath & " X " & ISOPath & " " & DestinationFolder, DontShowWindow, WaitUntilFinished)
- Set objShell = Nothing
- End Sub
- Sub ExtractISOButton( )
- If document.getElementById("CleanDestinationFirst").checked = true Then
- Call DeleteFolderContents
- End If
- If document.getElementById( "isDeleteFolderContentsSuccessful" ).value = "true" Then
- Call ExtractISO
- 'If document.getElementById( "isISOExtractionSuccessful" ).value = "true" Then
- document.getElementById( "OutputResult" ).innerHTML = "Extraction Result: " & WinRARExitCodeToString(document.getElementById( "WinRARExitCode" ).value)
- 'Else
- ' document.getElementById( "OutputResult" ).innerHTML = "ISO file extraction failed."
- 'End If
- Else
- document.getElementById( "OutputResult" ).innerHTML = "An error occurred while cleaning the destination folder. ISO extraction has been cancelled."
- End If
- End Sub
- Sub Reset( )
- document.getElementById( "WinRARExitCode" ).value = ""
- document.getElementById( "isDeleteFolderContentsSuccessful" ).value = ""
- End Sub
- Function SourceISOPathTxtBoxValue()
- SourceISOPathTxtBoxValue = document.getElementById( "SourceISOPathTxtBox" ).value
- End Function
- Function ExtractDestinationFolderTxtBoxValue()
- ExtractDestinationFolderTxtBoxValue = document.getElementById( "ExtractDestinationFolderTxtBox" ).value
- End Function
- Function WinRARExitCodeToString(ExitCode)
- Dim ExitCodeDescription
- Select Case ExitCode
- Case "0"
- ExitCodeDescription = " Successful operation."
- Case "1"
- ExitCodeDescription = " Warning. Non fatal error(s) occurred."
- Case "2"
- ExitCodeDescription = " A fatal error occurred."
- Case "3"
- ExitCodeDescription = " Invalid checksum. Data is damaged."
- Case "4"
- ExitCodeDescription = " Attempt to modify a locked archive."
- Case "5"
- ExitCodeDescription = " Write error."
- Case "6"
- ExitCodeDescription = " File open error."
- Case "7"
- ExitCodeDescription = " Wrong command line option."
- Case "8"
- ExitCodeDescription = " Not enough memory."
- Case "9"
- ExitCodeDescription = " File create error."
- Case "10"
- ExitCodeDescription = " No files matching the specified mask and options were found."
- Case "11"
- ExitCodeDescription = " Wrong password."
- Case "255"
- ExitCodeDescription = " User break."
- End Select
- WinRARExitCodeToString = ExitCodeDescription
- End Function
- </script>
- <body>
- <p align="center"><input type="text" id="SourceISOPathTxtBox" style="width:235px" />
-
- <input type="button" value="Select ISO File..." style="width:175px" onclick="SelectISOFile" /></p>
- <p align="center"><input type="text" id="ExtractDestinationFolderTxtBox" style="width:235px" />
-
- <input type="button" value="Select Extraction Folder..." style="width:175px" onclick="SelectFolder" /></p>
- <p align="center"><input type="checkbox" id="CleanDestinationFirst" checked>Clean Extract Folder Before Extraction</></p>
- <p align="center"><input type="button" value="Extract ISO" style="width:175px" onclick="ExtractISOButton" /></p>
- <input type="hidden" id="isDeleteFolderContentsSuccessful" value="true">
- <input type="hidden" id="WinRARExitCode" value="">
- <p id="OutputResult"></p>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement