HTM Dynamic Multi-Selection List Box with a batch backbone

Posted on 2010-09-19
Medium Priority
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]”

(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.


::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 HKName1=HKCU\Software\Microsoft\Windows\CurrentVersion\Run
 SET HKName2=HKLM\Software\Microsoft\Windows\CurrentVersion\Run
 SET HKName3=HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\load
 SET HKName4=HKLM\Software\Microsoft\Windows NT\CurrentVersion\Windows\load
 SET HKName5=HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell
SET HK6=HKLMUserinit
 SET HKName6=HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit


::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
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 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 Found inside !HKName%%A!>>"%tempLocation%\results.txt"
		TYPE "%tempLocation%\!HK%%A!Bad4.tmp">>"%tempLocation%\results.txt"
		ECHO *********************************************************************************************>>"%tempLocation%\results.txt"

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


Open in new window

Question by:nct1

Author Comment

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.

Accepted Solution

VeganBen earned 2000 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.

Expert Comment

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.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

862 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