Solved

HTM Dynamic Multi-Selection List Box with a batch backbone

Posted on 2010-09-19
3
289 Views
Last Modified: 2012-08-13
I've created a batch file that reads keys in the registry and then lists the relevant keys in a text file. I'm attempting to create a GUI for this batch that will allow the user to view the keys and then select what he/she wants to delete (basically reinventing HijackThis but for our own purposes). I figured I could do this with HTM just because there are a lot of tools out there to write this but as it turns out, I just don't know HTM coding and I can't figure out how to do this.

So here's the idea, the batch exports a tmp file whose name specifies where the key is located (eg: HKLMRun.tmp or HKLMShell.tmp). I'd like to create something that reads that text file and lists the contents in a Multi-Selection List Box and then just click a button that runs a batch file with a parameter (something like “delkey.bat” HKLMRun mySelection(i)). I have no problem with the Batch side; the HTM/JS side has left me at a standstill.

The batch is already ready to export in the following two formats:
“    [VALUE ]   [DATA]”

Or
(A more human friendly)

“Value:     [Value]”
“Data: [Data]”



The “DATA” side is actually irrelevant to the functionality and is really only there for the user to see.

I realise this all may sound complicated so please feel free to ask me anything about it for clarification. There's no rush on this, I've been playing with it for months now.

Below is the batch side that fuctions just fine, just with no real GUI, user interaction, or fuction, it just reads and displays the keys.

@ECHO OFF


::The def variable will eventually be updated from our servers rather than hard coded in the batch.
SET def=MSASCui.exe winvnc.exe KaUsrTsk.exe egui.exe wcescomm.exe ctfmon.exe Atiptaxx.exe ccApp.exe daemon.exe VPTray.exe VxTaskbarMgr.exe OmniPage 

QuickBooks qttask.exe Symantec mobsync.exe schedhlp.exe cpqteam.exe palmwizard.exe AbyssWebServer sidebar.exe UnlockerAssistant GrooveMonitor



SetLocal EnableDelayedExpansion
ECHO Gathering Info...
SET tempLocation=%temp%\StonewallRegistry
IF NOT EXIST "%tempLocation%" MD "%tempLocation%"
DEL /F/Q "%tempLocation%\*.*"

::Set Tmp Files Names

SET HK1=HKCURuns
 SET HKName1=HKCU\Software\Microsoft\Windows\CurrentVersion\Run
SET HK2=HKLMRuns
 SET HKName2=HKLM\Software\Microsoft\Windows\CurrentVersion\Run
SET HK3=HKCULoad
 SET HKName3=HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\load
SET HK4=HKLMLoad
 SET HKName4=HKLM\Software\Microsoft\Windows NT\CurrentVersion\Windows\load
SET HK5=HKLMShell
 SET HKName5=HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell
SET HK6=HKLMUserinit
 SET HKName6=HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit






SET MaxHK=6


::Export the keys
reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Run">"%tempLocation%\%HK1%.tmp"
reg query "HKLM\Software\Microsoft\Windows\CurrentVersion\Run">"%tempLocation%\%HK2%.tmp"
reg query "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows" /v load>"%tempLocation%\%HK3%.tmp"
reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Windows" /v load>"%tempLocation%\%HK4%.tmp"
reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Shell>"%tempLocation%\%HK5%.tmp"
reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Userinit>"%tempLocation%\%HK6%.tmp"






ECHO Stonewall's Registry Results>>"%tempLocation%\results.txt"
ECHO Date: %Date%>>"%tempLocation%\results.txt"
ECHO Time: %Time%>>"%tempLocation%\results.txt"

::Read the exported registry files
FOR /L %%A IN (1,1,%MaxHK%) DO (
	SET SkipMe=0
	FINDSTR /i "REG_SZ REG_MULTI_SZ REG_BINARY REG_DWORD REG_EXPAND_SZ" "%tempLocation%\!HK%%A!.tmp">"%tempLocation%\!HK%%A!2.tmp"
	FINDSTR /i /v "%def%" "%tempLocation%\!HK%%A!2.tmp">"%tempLocation%\!HK%%A!Bad.tmp"
	FOR /F "usebackq tokens=1,3 delims=	" %%K IN ("%tempLocation%\!HK%%A!Bad.tmp") DO (
		ECHO %%K>>"%tempLocation%\!HK%%A!Bad2.tmp"
		ECHO Value: %%K>>"%tempLocation%\!HK%%A!Bad4.tmp
		ECHO  Data: %%L>>"%tempLocation%\!HK%%A!Bad4.tmp
		ECHO %%K    %%L>>"%tempLocation%\!HK%%A!Bad5.tmp
	)



REM			 ::Tweaks
REM			  ::Keeps keys that are fine from being listed and allows the script to continue
			IF NOT EXIST "%tempLocation%\!HK%%A!Bad2.tmp" (
				SET SkipMe=1
				ECHO>>"%tempLocation%\!HK%%A!Bad2.tmp"
			)
			
REM			 ::Tweaks


REM	 ::Cleans up the results (someone else wrote this)
	FOR /F "usebackq tokens=* delims= " %%a IN ("%tempLocation%\!HK%%A!Bad2.tmp") DO (
		SET /A N+=1
		IF !N! GTR 3 (
			ECHO %%a >>"%tempLocation%\!HK%%A!Bad3.tmp"
		) ELSE (
			SET str=%%a
			SET str=!str:"=!
			ECHO !str! >>"%tempLocation%\!HK%%A!Bad3.tmp"
		)
	)

REM	 ::Lists the results in the command window
	IF !SkipMe! EQU 0 (
		ECHO.
		ECHO.
		ECHO Found inside !HKName%%A!
		TYPE "%tempLocation%\!HK%%A!Bad4.tmp"
		
REM		 ::List the results in the txt file to be read (or saved) by the user
		ECHO.>>"%tempLocation%\results.txt"
		ECHO.>>"%tempLocation%\results.txt"
		ECHO.>>"%tempLocation%\results.txt"
		ECHO *********************************************************************************************>>"%tempLocation%\results.txt"
		ECHO Found inside !HKName%%A!>>"%tempLocation%\results.txt"
		TYPE "%tempLocation%\!HK%%A!Bad4.tmp">>"%tempLocation%\results.txt"
		ECHO *********************************************************************************************>>"%tempLocation%\results.txt"
	)

)
ECHO.
ECHO.
ECHO Data has been stored in "%tempLocation%\results.txt"
notepad "%tempLocation%\results.txt"




:END

Open in new window

0
Comment
Question by:nct1
3 Comments
 

Author Comment

by:nct1
ID: 33712876
BTW, I'm plan to add a lot more keys to be read and tweaks for the keys, this part was just a test.
0
 
LVL 3

Accepted Solution

by:
VeganBen earned 500 total points
ID: 33713003
This sounds like a lot, but it's not so bad really.

First off, you have to get your txt file in a format which can be more easily read by javascript.

You can obviously "do" programming, so a quick glance at www.json.org will sort you out with a data structure.
0
 
LVL 7

Expert Comment

by:CitizenRon
ID: 34422727
Could you post a few lines of the "results.txt" file so that the front-end could more easily be designed based on the exact data format?

I've made quite a few "Hypertext Application" (HTA) GUIs for things that I have to do over and over that require more interactivity than a simple script can provide.  A HTA doesn't have the browser-host security restrictions involved like a plain HTML solution would even though it runs in IE.  My projects have included Dynamic HTML based on source files almost exactly like what you're proposing so it shouldn't be hard to adapt one to do what you need.

Would it matter if it used Javascript or VBScript?  I'm much more familiar with VBScript and since it would be an HTA running in IE only, either language would work fine.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Safari On Gmail only html 12 58
Command prompt output to variable? 9 46
paypal ipn url 5 58
Windows updates batch files 7 45
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question