Advertisement
atheos42

USB-Drive-Wipe

Jul 19th, 2024 (edited)
574
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VBScript 6.81 KB | Source Code | 0 0
  1. <html>
  2. <head>
  3. <title>USB Drive Wipe</title>
  4. <HTA:APPLICATION
  5.   APPLICATIONNAME="USB Drive Wipe"
  6.   ID="USB-Drive-Wipe"
  7.   VERSION="1.0"
  8.   ICON="Hardware.ico"
  9.   SCROLL="auto"
  10.   SINGLEINSTANCE="yes"
  11.   WINDOWSTATE="normal"/>
  12.  
  13. <!--Begin Vbscript-->
  14. <script language="VBScript">
  15. On Error Resume Next
  16.  
  17. Dim DefaultDrive
  18. Dim strHelp
  19.  
  20. strHelp = "Wipe Drive button - Wipe the drive selected in the Drive list box" & vbcrlf &_
  21. "Refresh button - Refresh list of available drives" & vbcrlf &_
  22. "Reset button - Resets Drive, File System, and Passes to default values."
  23.  
  24. '********************************************************************************
  25.  
  26. Sub window_Onload
  27.  
  28.   window.resizeTo 500,200
  29.   Call RefreshDrives
  30.  
  31. End sub
  32.  
  33. '********************************************************************************
  34. ' Wipe selected drive.
  35. Sub WipeDrive
  36.   Dim wsh
  37.   Set wsh = CreateObject("Wscript.Shell")
  38.   Dim strMsg
  39.   Dim strCmd
  40.   Dim iAnswer
  41.   'The S parameter does not do anything on its own
  42.  '/S      Modifies the treatment of string after /C or /K (see below)
  43.  '/C      Carries out the command specified by string and then terminates  
  44.  '/K      Carries out the command specified by string but remains  
  45.  strMsg = "Are you sure you want to Wipe Drive " & Drives.Value & ": ?"
  46.   strCmd = "cmd.exe /S /C format " & Drives.Value & ": /fs:" & FileSystem.Value & " /p:" & Passes.Value
  47.   iAnswer = Msgbox(strMsg, vbYesNo, "Wipe Drive?")
  48.   If iAnswer = vbNo Then Exit Sub
  49.   wsh.Run strCmd, 1, True
  50.  
  51. End Sub
  52.  
  53. '********************************************************************************
  54. ' Find available drives and add to list box, and set DefaultDrive
  55. Sub RefreshDrives
  56.  
  57.   For Each d In CreateObject("Scripting.FileSystemObject").Drives
  58.     'Debug.Print d.DriveLetter, d.Path, d.ShareName
  59.     If d.DriveLetter <> "C" and d.DriveLetter <> "D" Then
  60.     'If d.DriveLetter <> "C" Then
  61.         'Msgbox(d.DriveLetter)
  62.         Set objOption = Document.createElement("OPTION")
  63.         objOption.Text = d.DriveLetter
  64.         objOption.Value = d.DriveLetter
  65.         Drives.Add(objOption)
  66.         If DefaultDrive = "" Then DefaultDrive = d.DriveLetter
  67.         'Msgbox DefaultDrive
  68.     End If
  69.   Next
  70.  
  71. End Sub
  72.  
  73. '********************************************************************************
  74. 'Reset User Input fields to default data.
  75. Sub ResetData
  76.   Drives.Value = DefaultDrive
  77.   FileSystem.Value = "NTFS"
  78.   Passes.Value = 1
  79. End Sub
  80.  
  81. '********************************************************************************
  82. ' Show Help Message.
  83. Sub ShowHelp
  84.   Msgbox(strHelp)
  85. End Sub
  86.  
  87. '********************************************************************************
  88.  
  89. Sub ExitWindow
  90.     Call CleanUp
  91.     window.close
  92. End Sub
  93.  
  94. '********************************************************************************
  95.  
  96. Sub CleanUp
  97.  
  98. End Sub
  99.  
  100. '********************************************************************************
  101. ' Various Test subs for development testing, not used in production.
  102. Sub TestSub
  103.     Exit Sub
  104.     For Each objOption in FileSystem.Options
  105.         If objOption.Selected Then
  106.                 Msgbox objOption.InnerText
  107.         End If
  108.     Next
  109. End Sub
  110.  
  111. Sub TestSub2
  112.     Exit Sub
  113.     For Each objOption in Passes
  114.         If objOption.Selected Then
  115.                 Msgbox objOption.InnerText
  116.         End If
  117.     Next
  118. End Sub
  119.  
  120. '********************************************************************************
  121. </script>
  122. <!--CSS CODE -->
  123. <style type="text/css">
  124. <!---->
  125.  
  126. #navcontainer
  127. {
  128. background: #000;
  129. border-top: 1px solid #888888;
  130. border-bottom: 1px solid #888888;
  131. border-right: 1px solid #888888;
  132. border-left: 1px solid #888888;
  133. font: bold 12px Verdana, sans-serif;
  134. }
  135.  
  136. #navlist
  137. {
  138. list-style: none outside none;
  139. margin: 0;
  140. padding: 0;
  141. }
  142.  
  143. @media all {
  144. #navlist {
  145. text-align: center
  146. }
  147. }
  148.  
  149. #navlist li
  150. {
  151. bottom: 1px;
  152. display: inline;
  153. line-height: 1.2em;
  154. margin: 0;
  155. padding: 0;
  156. position: relative;
  157. }
  158.  
  159. html>body #navlist li
  160. {
  161. background: #000;
  162. margin: 0 3px 0 0;
  163. padding: 4px 0px 4px 0;
  164. }
  165.  
  166. #navlist a, #navlist a:link, #navlist a:visited a:hover
  167. {
  168. background: #999999;
  169. border: 1px solid #000000;
  170. bottom: 1px;
  171. color: #222222;
  172. cursor: pointer;
  173. display: inline;
  174. height: 1em;
  175. margin: 0;
  176. padding: 3px 5px 3px 5px;
  177. position: relative;
  178. right: 2px;
  179. text-decoration: none;
  180. }
  181.  
  182. #navlist a:hover
  183. {
  184. background: #555555;
  185. bottom: 1px;
  186. color: #22dd22;
  187. position: relative;
  188. right: 1px;
  189. }
  190.  
  191. #navlist a:active
  192. {
  193. background: #555555;
  194. bottom: 0px;
  195. color: #00dd00;
  196. position: relative;
  197. right: 0px;
  198. }
  199.  
  200. th {
  201. background-color:#000000;
  202. }
  203.  
  204. table, th, td {
  205. border:1px solid gray;
  206. border-collapse: collapse;
  207. }
  208.  
  209. table {
  210. width:100%;
  211. font: 16px;
  212. }
  213.  
  214. td, th {
  215. white-space: nowrap;
  216. }
  217.  
  218. a.gobutton
  219. {
  220. font:bold 10px Verdana, sans-serif;
  221. text-align: center;
  222. background: #999999;
  223. border: 1px solid #000000;
  224. bottom: 2px;
  225. color: #222222;
  226. cursor: pointer;
  227. display: inline;
  228. height: 1em;
  229. margin: 0;
  230. padding: 3px 5px 3px 5px;
  231. position: relative;
  232. right: 2px;
  233. text-decoration: none;
  234. }
  235.  
  236. a.gobutton:hover
  237. {
  238. background: #555555;
  239. bottom: 1px;
  240. color: #DDD;
  241. position: relative;
  242. right: 1px;
  243. }
  244.  
  245. a.gobutton:active
  246. {
  247. background: #555555;
  248. bottom: 0px;
  249. color: #000;
  250. position: relative;
  251. right: 0px;
  252. }
  253.  
  254. </style>
  255. </head>
  256.  
  257. <!--HTML CODE-->
  258. <body STYLE="font:14 pt palatino; color:black;
  259. filter:progid:DXImageTransform.Microsoft.Gradient
  260. (GradientType=0, StartColorStr='#222222', EndColorStr='#666666')">
  261. <p>
  262. <span id = "ControlsArea"></span>
  263. </p>
  264. <div id="navcontainer">
  265. <ul id="navlist">
  266. <!-- <li><a onclick="Notepad" href="#">Edit Exclusion List</a></li> -->
  267. <li><a onclick="WipeDrive" href="#">Wipe Drive</a></li>
  268. <li><a onclick="RefreshDrives" href="#">Refresh</a></li>
  269. <li><a onclick="ResetData" href="#">Reset</a></li>
  270. <li><a onclick="ShowHelp" href="#">Help</a></li>
  271. <li><a onclick="ExitWindow" href="#">Exit</a></li>
  272. </ul>
  273. </div>
  274. <p>
  275. <span id = "DataArea"></span>
  276. </p>
  277. <div id="navcontainer">
  278. <ul id="navlist">
  279. &#xF6DD; Drive
  280. <select id="Drives" size="1" name="Drives" >
  281. </select>
  282. File System
  283. <select id=FileSystem size="1" name="FileSystem" onChange="TestSub">
  284.     <option value="NTFS">NTFS</option>
  285.     <option value="FAT32">FAT32</option>
  286. </select>
  287. Passes
  288. <select id=Passes size="1" name="Passes" onChange="TestSub2">
  289.     <option value="1">1</option>
  290.     <option value="2">2</option>
  291.     <option value="3">3</option>
  292. </select>
  293. </ul>
  294. </div>
  295.  
  296. </body>
  297. </html>
  298.  
  299. <!--
  300. ' References:
  301. ' https://www.tek-tips.com/viewthread.cfm?qid=1763636
  302. ' https://stackoverflow.com/questions/29548613/hta-how-to-pick-up-value-from-each-drop-down-list-and-search
  303. ' https://stackoverflow.com/questions/39210888/find-letter-assigned-to-main-drive
  304. ' https://stackoverflow.com/questions/17956651/execute-a-command-in-command-prompt-using-excel-vba
  305. ' https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/format
  306. -->
Tags: hta
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement