Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <title>Execution of command line with HTA by © Najeeb © 2021</title>
- <head>
- <HTA:APPLICATION
- APPLICATIONNAME="Execution of command line with HTA by © Najeeb © 2021"
- SCROLL="no"
- SINGLEINSTANCE="yes"
- WINDOWSTATE="maximize"
- ICON="N2.ico";"N.ico";"Winver.exe"
- />
- </head>
- <META HTTP-EQUIV="MSThemeCompatible" CONTENT="YES">
- <script language="VBScript">
- Option Explicit
- Dim Title : Title = "Execution of command line with HTA by © Najeeb © 2021"
- '**********************************************************************************************
- Sub Window_OnLoad
- Call Run_Cmd("help")
- End Sub
- '**********************************************************************************************
- Sub Run_Cmd(strCommand)
- On Error Resume Next
- If input.value = "" Then
- MsgBox "ATTENTION ! The text box is empty !"& vbcr &_
- "You forgot to type a command on the text box !",vbExclamation,Title
- input.value = "help"
- Exit Sub
- End if
- Output.value = ""
- btnClick.disabled = True
- document.body.style.cursor = "wait"
- btnClick.style.cursor = "wait"
- Const ForReading = 1
- Const TristateTrue = -1
- Const TemporaryFolder = 2
- Const WshHide = 0
- Dim wsh, fs, ts
- Dim strTempFile,strFile, strData
- Set wsh = CreateObject("Wscript.Shell")
- Set fs = CreateObject("Scripting.FileSystemObject")
- strTempFile = fs.BuildPath(fs.GetSpecialFolder(TemporaryFolder).Path, fs.GetTempName)
- strFile = fs.BuildPath(fs.GetSpecialFolder(TemporaryFolder).Path, "result.txt")
- wsh.Run "cmd.exe /c " & strCommand & " > " & DblQuote(strTempFile) & "2>&1", WshHide, True
- wsh.Run "cmd.exe /u /c Type " & DblQuote(strTempFile) & " > " & DblQuote(strFile) & "", WshHide, True
- Set ts = fs.OpenTextFile(strFile,ForReading,True,TristateTrue)
- strData = ts.ReadAll
- Output.Value = "Microsoft Windows [version 7.1 7631]" & vbcrlf &_
- "Copyright (c) 2009 Microsoft Corporation. All rights reserved." & vbcrlf & vbcrlf &_
- "C:\>"& strCommand & vbcrlf & strData
- ts.Close
- fs.DeleteFile strTempFile
- fs.DeleteFile strFile
- document.body.style.cursor = "default"
- btnClick.style.cursor = "default"
- btnClick.disabled = False
- End Sub
- '**********************************************************************************************
- Function DblQuote(Str)
- DblQuote = Chr(34) & Str & Chr(34)
- End Function
- '**********************************************************************************************
- Sub OnClickButtonCopy()
- document.parentwindow.clipboardData.SetData "text", Output.Value
- MsgBox "The ouput result is copied to the clipboard !",vbInformation,Title
- End Sub
- '**********************************************************************************************
- </script>
- <script language="VBScript" defer=true>
- Sub Ip_Publique
- Dim Titre,URL,ie,objFSO,Data,OutPut,objRegex,Match,Matches
- Titre = "Public IP Address !"
- URL = "http://monip.org"
- Set ie = CreateObject("InternetExplorer.Application")
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- ie.Navigate (URL)
- ie.Visible=false
- DO WHILE ie.busy
- Sleep 100
- LOOP
- Data = ie.document.documentElement.innertext
- ie.Quit
- Set ie = Nothing
- Set objRegex = new RegExp
- objRegex.Pattern = "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"
- objRegex.Global = False
- objRegex.IgnoreCase = True
- Set Matches = objRegex.Execute(Data)
- For Each Match in Matches
- ip_public.InnerHTML = Match.Value
- Next
- End Sub
- Sub Sleep(MSecs)' Function to take a break because wscript.sleep does not work in an HTA
- Set fso = CreateObject("Scripting.FileSystemObject")
- Dim tempFolder : Set tempFolder = fso.GetSpecialFolder(2)
- Dim tempName : tempName = "Sleeper.vbs"
- If Fso.FileExists(tempFolder&"\"&tempName)=False Then
- Set objOutputFile = fso.CreateTextFile(tempFolder&"\"&tempName, True)
- objOutputFile.Write "wscript.sleep WScript.Arguments(0)"
- objOutputFile.Close
- End If
- CreateObject("WScript.Shell").Run tempFolder&"\"&tempName &" "& MSecs,1,True
- End Sub
- </script>
- </head>
- <body bgcolor="123456" text=Darkorange>
- <hr>
- <center><FONT SIZE="3"><B><I>Some examples of commands</I></B></FONT><BR>
- <img src="N.ico" alt="Najeeb Shah Khan" align="right">
- <select style="background-color:lightblue" name="DropDown">
- <option value="Tasklist">Tasklist</option>
- <option value="TYPE %windir%\CMD.fm">MY ALL COMMANDS</option>
- <option value="PCI.hta">ALL COMPUTER INFO</option>
- <option value="Netstat -A">Netstat</option>
- <option value="Start %windir%">WINDOWS</option>
- <option value="Start %TEMP%">TEMP FOLDER</option>
- <option value="Start %APPDATA%">APPDATA</option>
- <option value="Start Shell:Startup">STARTUP FOLDER</option>
- <option value="CD %windir%\ | NOTE.hta">MY NOTEPAD</option>
- <option value="CD %windir%\ | NOTEREAD.hta">NOTE&READ</option>
- <option value="CD %Programfiles%\Mozilla Firefox\ | Start Firefox.exe">CD %Programfiles%\Mozilla Firefox\ | Start Firefox.exe</option>
- <option value="Tracert www.google.fr">Tracert www.google.fr</option>
- <option value="Start mspaint">Start Mspaint</option>
- <option value="Start Notepad">Start Notepad</option>
- <option value="Start write">Start word</option>
- <option value="Start %WinDir%\nircmd.exe emptybin">Recycle Bin</option>
- <option value="Start %WinDir%\nircmd.exe cmdwait 2000 savescreenshot C:\Users\%USERNAME%\Desktop\Screen%%random%%.jpg">Screen Shot</option>
- <option value="Start %WinDir%\RAr.exe a NSK.rar %CD% -psonyNSK007">RAR</option>
- <option value="Start %WinDir%\UnRAR.exe x *.rar -PsonyNSK007">UNRAR</option>
- <option value="Explorer.exe /n,/e,/root,C:\Program Files">Explorer.exe /n,/e,/root,C:\Program Files</option>
- <option value="Ipconfig /all">IpConfig</option>
- <option value="Dir /A">Dir</option>
- <option value="Start iexplore">Start iexplore</option>
- <option value="Taskkill /im iexplore.exe /f">Taskkill /im iexplore.exe /f</option>
- </select>
- <input type="button" onClick="Run_Cmd(DropDown.value)" value="Run this command">
- <center><hr><B><I>Type your input command here</I></B><br>
- <input type="text" Name="input" size="10"style="width:100%" value="Ping www.google.com" style="background-color:lightblue">
- <input type="submit" name="btnClick" value="Run the input command line" onclick="Run_Cmd(input.value)">
- <br><hr><B><I> The output result (readonly)</I></B><hr>
- <textarea readonly NAME="Txtarea" id="Output" style="width:100%" rows="28" style="background-color:black; color:Darkorange">Microsoft Windows [version 7.1 7631]
- Copyright (c) 2009 Microsoft Corporation. All rights reserved.
- C:\></textarea><input type="button" name="ButtonCopy" value="Copy the ouput result to the Clipboard" onclick="OnClickButtonCopy">
- <input type="button" class="button" style="cursor:hand;" value="Public IP" name="PublicIP" onClick="Ip_Publique()" style="font-weight: bold"><BR><font color="#669933"><span id="ip_public"></span></font><hr></center>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement