Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>USB Drive Wipe</title>
- <HTA:APPLICATION
- APPLICATIONNAME="USB Drive Wipe"
- ID="USB-Drive-Wipe"
- VERSION="1.0"
- ICON="Hardware.ico"
- SCROLL="auto"
- SINGLEINSTANCE="yes"
- WINDOWSTATE="normal"/>
- <!--Begin Vbscript-->
- <script language="VBScript">
- On Error Resume Next
- Dim DefaultDrive
- Dim strHelp
- strHelp = "Wipe Drive button - Wipe the drive selected in the Drive list box" & vbcrlf &_
- "Refresh button - Refresh list of available drives" & vbcrlf &_
- "Reset button - Resets Drive, File System, and Passes to default values."
- '********************************************************************************
- Sub window_Onload
- window.resizeTo 500,200
- Call RefreshDrives
- End sub
- '********************************************************************************
- ' Wipe selected drive.
- Sub WipeDrive
- Dim wsh
- Set wsh = CreateObject("Wscript.Shell")
- Dim strMsg
- Dim strCmd
- Dim iAnswer
- 'The S parameter does not do anything on its own
- '/S Modifies the treatment of string after /C or /K (see below)
- '/C Carries out the command specified by string and then terminates
- '/K Carries out the command specified by string but remains
- strMsg = "Are you sure you want to Wipe Drive " & Drives.Value & ": ?"
- strCmd = "cmd.exe /S /C format " & Drives.Value & ": /fs:" & FileSystem.Value & " /p:" & Passes.Value
- iAnswer = Msgbox(strMsg, vbYesNo, "Wipe Drive?")
- If iAnswer = vbNo Then Exit Sub
- wsh.Run strCmd, 1, True
- End Sub
- '********************************************************************************
- ' Find available drives and add to list box, and set DefaultDrive
- Sub RefreshDrives
- For Each d In CreateObject("Scripting.FileSystemObject").Drives
- 'Debug.Print d.DriveLetter, d.Path, d.ShareName
- If d.DriveLetter <> "C" and d.DriveLetter <> "D" Then
- 'If d.DriveLetter <> "C" Then
- 'Msgbox(d.DriveLetter)
- Set objOption = Document.createElement("OPTION")
- objOption.Text = d.DriveLetter
- objOption.Value = d.DriveLetter
- Drives.Add(objOption)
- If DefaultDrive = "" Then DefaultDrive = d.DriveLetter
- 'Msgbox DefaultDrive
- End If
- Next
- End Sub
- '********************************************************************************
- 'Reset User Input fields to default data.
- Sub ResetData
- Drives.Value = DefaultDrive
- FileSystem.Value = "NTFS"
- Passes.Value = 1
- End Sub
- '********************************************************************************
- ' Show Help Message.
- Sub ShowHelp
- Msgbox(strHelp)
- End Sub
- '********************************************************************************
- Sub ExitWindow
- Call CleanUp
- window.close
- End Sub
- '********************************************************************************
- Sub CleanUp
- End Sub
- '********************************************************************************
- ' Various Test subs for development testing, not used in production.
- Sub TestSub
- Exit Sub
- For Each objOption in FileSystem.Options
- If objOption.Selected Then
- Msgbox objOption.InnerText
- End If
- Next
- End Sub
- Sub TestSub2
- Exit Sub
- For Each objOption in Passes
- If objOption.Selected Then
- Msgbox objOption.InnerText
- End If
- Next
- End Sub
- '********************************************************************************
- </script>
- <!--CSS CODE -->
- <style type="text/css">
- <!---->
- #navcontainer
- {
- background: #000;
- border-top: 1px solid #888888;
- border-bottom: 1px solid #888888;
- border-right: 1px solid #888888;
- border-left: 1px solid #888888;
- font: bold 12px Verdana, sans-serif;
- }
- #navlist
- {
- list-style: none outside none;
- margin: 0;
- padding: 0;
- }
- @media all {
- #navlist {
- text-align: center
- }
- }
- #navlist li
- {
- bottom: 1px;
- display: inline;
- line-height: 1.2em;
- margin: 0;
- padding: 0;
- position: relative;
- }
- html>body #navlist li
- {
- background: #000;
- margin: 0 3px 0 0;
- padding: 4px 0px 4px 0;
- }
- #navlist a, #navlist a:link, #navlist a:visited a:hover
- {
- background: #999999;
- border: 1px solid #000000;
- bottom: 1px;
- color: #222222;
- cursor: pointer;
- display: inline;
- height: 1em;
- margin: 0;
- padding: 3px 5px 3px 5px;
- position: relative;
- right: 2px;
- text-decoration: none;
- }
- #navlist a:hover
- {
- background: #555555;
- bottom: 1px;
- color: #22dd22;
- position: relative;
- right: 1px;
- }
- #navlist a:active
- {
- background: #555555;
- bottom: 0px;
- color: #00dd00;
- position: relative;
- right: 0px;
- }
- th {
- background-color:#000000;
- }
- table, th, td {
- border:1px solid gray;
- border-collapse: collapse;
- }
- table {
- width:100%;
- font: 16px;
- }
- td, th {
- white-space: nowrap;
- }
- a.gobutton
- {
- font:bold 10px Verdana, sans-serif;
- text-align: center;
- background: #999999;
- border: 1px solid #000000;
- bottom: 2px;
- color: #222222;
- cursor: pointer;
- display: inline;
- height: 1em;
- margin: 0;
- padding: 3px 5px 3px 5px;
- position: relative;
- right: 2px;
- text-decoration: none;
- }
- a.gobutton:hover
- {
- background: #555555;
- bottom: 1px;
- color: #DDD;
- position: relative;
- right: 1px;
- }
- a.gobutton:active
- {
- background: #555555;
- bottom: 0px;
- color: #000;
- position: relative;
- right: 0px;
- }
- </style>
- </head>
- <!--HTML CODE-->
- <body STYLE="font:14 pt palatino; color:black;
- filter:progid:DXImageTransform.Microsoft.Gradient
- (GradientType=0, StartColorStr='#222222', EndColorStr='#666666')">
- <p>
- <span id = "ControlsArea"></span>
- </p>
- <div id="navcontainer">
- <ul id="navlist">
- <!-- <li><a onclick="Notepad" href="#">Edit Exclusion List</a></li> -->
- <li><a onclick="WipeDrive" href="#">Wipe Drive</a></li>
- <li><a onclick="RefreshDrives" href="#">Refresh</a></li>
- <li><a onclick="ResetData" href="#">Reset</a></li>
- <li><a onclick="ShowHelp" href="#">Help</a></li>
- <li><a onclick="ExitWindow" href="#">Exit</a></li>
- </ul>
- </div>
- <p>
- <span id = "DataArea"></span>
- </p>
- <div id="navcontainer">
- <ul id="navlist">
-  Drive
- <select id="Drives" size="1" name="Drives" >
- </select>
- File System
- <select id=FileSystem size="1" name="FileSystem" onChange="TestSub">
- <option value="NTFS">NTFS</option>
- <option value="FAT32">FAT32</option>
- </select>
- Passes
- <select id=Passes size="1" name="Passes" onChange="TestSub2">
- <option value="1">1</option>
- <option value="2">2</option>
- <option value="3">3</option>
- </select>
- </ul>
- </div>
- </body>
- </html>
- <!--
- ' References:
- ' https://www.tek-tips.com/viewthread.cfm?qid=1763636
- ' https://stackoverflow.com/questions/29548613/hta-how-to-pick-up-value-from-each-drop-down-list-and-search
- ' https://stackoverflow.com/questions/39210888/find-letter-assigned-to-main-drive
- ' https://stackoverflow.com/questions/17956651/execute-a-command-in-command-prompt-using-excel-vba
- ' https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/format
- -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement