Link to home
Start Free TrialLog in
Avatar of bsharath
bsharathFlag for India

asked on

Script to combine all the logs into 1 excel file.As per the selections in a UNC.

Hi,

Script to combine all the logs into 1 excel file.As per the selections in a UNC.

The actual script was provided by Joe
Its a HTA related to software capturing.
Original Q..
https://www.experts-exchange.com/questions/26309499/HTA-code-that-can-list-all-softwares-in-a-machine-and-have-a-small-box-to-enter-comments-in-them.html?anchorAnswerId=33213939#a33213939


Regards
Sharath
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

so simply create excel file while each worksheet name is the UNC and write the log files content, right?
I was thinking something like this would be a nice report viewer:
<html>
<head>
<hta:application
	ID="objSoftwareListViewer"
	ApplicationName="SoftwareListViewer"
	SINGLEINSTANCE="YES"
	CONTEXTMENU="NO"
/>

<title>Software List Viewer</title>

<head>

<script language="vbscript">
on error resume next

Dim strUNC
Dim strWindowTitle

Set fso=CreateObject("Scripting.FileSystemObject")

'--------------------------------------------------------------
'	User Variables
'--------------------------------------------------------------

strWindowTitle="Software List Viewer"


'Enter the UNC path
strUNC="\\SERVER123\MYSHARE"

'--------------------------------------------------------------


Sub Window_OnLoad
	GetTextFiles
End Sub

Sub GetTextFiles
	Set oFolder=fso.GetFolder(strUNC)
	
	html="<option value=""""></option>"
	For each file in oFolder.Files
		If right(lcase(file),4)=".txt" then
			html=html & "<option value=""" & file & """>" & fso.GetBaseName(file) & "</option>"
		End If
	Next
	
	ReportArea.innerHTMl="Select Report:  <select id=""selComputer"" onchange=""DisplayFile"">" & html & "</select>"
	
End Sub

Sub DisplayFile
	myFile=selComputer.value
	
	If myFile="" then 
		SoftwareArea.innerHTML=""
		Exit Sub
	End If
	
	If NOT fso.FileExists(myFile) then
		msgbox "File not found:  " & myFile,vbExclamation,strWindowTitle
		Exit Sub
	End If
	
	Set oFile=fso.OpenTextFile(myFile,1)
	text=oFile.ReadAll
	oFile.close
	
	arrText=split(text,vbCrLf)
	
	count=0
	html="<table><th>#</th><th>Software Title</th><th>Description</th>"
	For each line in arrText
		If Instr(line,vbTab) then
			skip = False
			If Instr(line,"AUTHORIZED") then
				If checkAuthorized.checked=True then
					skip=False
				Else
					skip=True
				End If
				
			End If
			
			If skip=False then
				count=count+1
				If count mod 2 = 0 then
					myClass="even"
				Else
					myClass="odd"
				End If
				arrLine="" : soft="" : desc=""
				arrLine=split(line,vbTab)
				soft=arrLine(0)
				desc=arrLine(1)
				html=html & "<tr><td class=""" & myClass & """>" & count & "</td><td class=""" & myClass & """>" & soft & "</td><td class=""" & myClass & """>" & desc & "</td></tr>"
			End If
		Else
			If Instr(line,"SN:") then SN_Area.innerHTML="<b>Serial Number:  </b>" & split(line,"SN:")(1)
			If Instr(line,"ROLE:") then RoleArea.innerHTML="<b>Role:  </b>" & split(line,"ROLE:")(1)
			If Instr(line,"MSDN:") then MSDN_Area.innerHTML="<b>MSDN User:  </b>" & split(line,"MSDN:")(1)
			If Instr(line,"SUBMITTED:") then SubmittedArea.innerHTML="<b>Submitted:  </b>" & split(line,"SUBMITTED:")(1)
			If Instr(line,"COMMENTS:") then CommentsArea.innerHTML="<b>Comments:  </b>" & split(line,"COMMENTS:")(1)

		End If
	Next
	html = html & "</table>"
	
	If count > 0 then 
		SoftwareArea.className="table"
		SoftwareArea.innerHTML=html
		CountArea.innerHTML="<b>Total:  </b>" & count
	Else
		SoftwareArea.className=""
		CountArea.innerHTML=""
		SoftwareArea.innerHTML="No unauthorized software."
	End If
	
End Sub


</script>

<style>
body
{
	font: 10pt arial;
	background-color: #303030;
	color: white;
}

td {
	font: 10pt arial;
	color: black;
	border: 1px solid black;
}

th {
	color: white;
	background-color: gray;
}

.odd{
	background-color: #f0f0f0;
}

.even {
	background-color: white;
}

table {
	border-collapse: collapse;
	background-color: white;
}

.table {
	height: 400px;
	overflow-y: scroll;
}

</style>

</head>
 
<body>
Show Authorized:  <input type="checkbox" id="checkAuthorized" checked onchange="DisplayFile">
<div id="ReportArea"></div><br>
<div id="SN_Area"></div>
<div id="RoleArea"></div>
<div id="MSDN_Area"></div>
<div id="SubmittedArea"></div><br>
<div id="SoftwareArea" class="table"></div>
<div id="CountArea"></div><br>
<div id="CommentsArea"></div>
</body>

</html>

Open in new window

Avatar of bsharath

ASKER

Thanks Joe
Will be back in some time and test
Any help with this
This Q u and Rob helped me its a extended Q...
https://www.experts-exchange.com/questions/26338605/Script-that-works-in-changing-one-domain-to-another-domain-will-need-a-change-to-disjoin-and-rejoin-a-same-domain.html
ASKER CERTIFIED SOLUTION
Avatar of jostrander
jostrander
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a lot Joe.. :-)