Solved

HTM Dynamic Multi-Selection List Box with a batch backbone

Posted on 2010-09-19
3
279 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…

762 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now