Need editing the HTA file

Hi,

I got this Hta file from EE.Need some editingThis script gets lots of details on the machine name entered.What i want is the HTA file asks for a file (txt) file that has many machinenames in it.So that it finds the logged in users and many details.

'==============
<head>
<title>Login Details of a Machine</title>
<HTA:APPLICATION
     APPLICATIONNAME="Login Details"
     BORDER="thin"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
>
</head>

<script language="VBScript">

Sub Window_onLoad
      Me.ResizeTo 400,300
    Me.MoveTo ((Screen.Width / 2) - 200),((Screen.Height / 2) - 150)
End Sub

Sub Default_Buttons
      If Window.Event.KeyCode = 13 Then
            btn_logindetails.Click
      End If
End Sub

Sub Get_Login_Details
   
      strComputer = txt_computer.value
     
      if strComputer = "" Then
            msgbox "Please enter a computer name or IP Address",vbOKOnly,"No Computer Name or IP Address"
            Exit Sub
      End If
     
      If Ping(strComputer) = False Then
        msgbox strComputer & " did not respond to ping. No action could be taken.",vbOkOnly, "Cannot continue script."
        Exit Sub
      End If      
     
      Set objWMIService = GetObject("winmgmts:" _
          & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
     
      Set colComputer = objWMIService.ExecQuery _
          ("Select * from Win32_ComputerSystem")
     
      Set colComputerIP = objWMIService.ExecQuery _
          ("Select * from Win32_NetworkAdapterConfiguration")
     
      Set colSystemInfo = objWMIService.ExecQuery _
          ("Select * from Win32_OperatingSystem",,48)
       
      For Each objComputer in colComputer
          strUserName = "User Name: " & objComputer.UserName
          strHostName = "Host Name: " & objComputer.Name
      Next
     
      For Each IPConfig in colComputerIP
            If Not IsNull(IPConfig.IPAddress) Then
              For intIPCount = LBound(IPConfig.IPAddress) _
                  to UBound(IPConfig.IPAddress)
                      strIPAddress = strIPAddress & "IP Address: " & IPConfig.IPAddress(intIPCount) & "~"
            next
            end if
      Next
     
      If Right(strIPAddress, 1) = "~" Then
            strIPAddress = Left(strIPAddress, Len(strIPAddress) - 1)
      End If
      strIPAddress = Replace(strIPAddress, "~", vbCrLf)
     
      For Each objItem in colSystemInfo
           strOS_Caption = "Caption: " & objItem.Caption
           strOS_SPVersion = "SP Version: " & objItem.CSDVersion
           strOS_VerNumber = "Version Number: " & objItem.Version
      Next
     
      MsgBox strUserName & vbcrlf & strHostName & vbcrlf & _
           strIPAddress & vbcrlf & strOS_Caption & vbcrlf & _
           strOS_SPVersion & vbcrlf & strOS_VerNumber, vbOKOnly, "Login Details"
   
End Sub

Function Ping(strComputer)
      Dim objShell, boolCode
      Set objShell = CreateObject("WScript.Shell")
      boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
      If boolCode = 0 Then
            Ping = True
      Else
            Ping = False
      End If
End Function

</script>

<body STYLE="font:14 pt arial; color:white;filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Buttons'>
      <table width='80%' height = '100%' align='center' border='0'>
            <tr height='20%'>
                  <td>
                  </td>
            </tr>
            <tr height='10%'>
                  <td align='center'>
                        Computer name or IP Address:
                  </td>
            </tr
            <tr height='20%'>
                  <td align='center'>
                        <input type="text" value="172.16.2.48" name="txt_computer" maxlength='15' size='16'>
                  </td>
            </tr>
            <tr height='30%'>
                  <td align='center'>
                        <input type="button" value="Check Machine" name="btn_logindetails"  onClick="Get_Login_Details">
                  </td>
            </tr>
            <tr height='20%'>
                  <td>
                  </td>
            </tr>

      </table>

</body>
'==============

I have many other ways to find the details but need editiing this script only as this fetches details realy fast and without any supporing tools.

Regards
Sharath
LVL 11
bsharathAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
chandru_solConnect With a Mentor Commented:
Try this,

Change the OU=Computerss to suit your needs. Try and do it an OU with less computers

regards
chandru
On error resume next
 
Const ADS_SCOPE_SUBTREE = 2
 
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
 
Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
    "Select Name, Location from 'LDAP://OU=Computers,DC=DOMAIN,DC=local' " _
        & "Where objectClass='computer'"  
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
 
Do Until objRecordSet.EOF
    
    ' Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value
    strComputer = objRecordSet.Fields("Name").Value
    
    Set objShell = CreateObject("WScript.Shell")
    strCommand = "%comspec% /c ping -n 3 -w 1000 " & strComputer & ""
    Set objExecObject = objShell.Exec(strCommand)
 
'clears echo replies left in strText from the previous loop
strText=""
 
 
Do While Not objExecObject.StdOut.AtEndOfStream
        strText = objExecObject.StdOut.ReadAll()
        If Instr(strText, "Reply") > 0 Then
 
 
            Set objWMIService = GetObject _
                ("winmgmts:\\" & strComputer & "\root\cimv2")
 	    Set colItems = objWMIService.ExecQuery _
                ("Select * From Win32_OperatingSystem")  
	    Set colItems2 = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
           ' Wscript.Echo Err.Description
	    Set colItems3 = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
	    Set colItems4 = objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)
 
	    For Each objItem in ColItems
                strOS = objItem.Caption
	    Next
		
	    For Each objItem in colItems2
		strDellTag = objItem.SerialNumber
		strManu = objItem.Manufacturer
	    Next
 
	    For Each objItem in colitems3
	        strUserName = objItem.Username
		strModel = objItem.Model
		strRAM = objItem.TotalPhysicalMemory
		strTimeZone = (objItem.CurrentTimeZone / 60)
		strDayLightSavings = objItem.DaylightInEffect
	    Next
	
	    For Each objItem in colitems4
		strProcessor = objItem.Name
            Next
		
		If Err.Number > 0 then
		  strErrorSystems =  strComputer & ", " & strErrorSystems 
		else
		  Wscript.Echo "-------------------------------------------------------------"
		  Wscript.Echo "Computer Name: " & strComputer & ", " & strUserName
		  Wscript.Echo "-------------------------------------------------------------"
	          Wscript.Echo "Operating System: " & strOS 
                  Wscript.Echo "Current User: " & strUserName
		  Wscript.Echo "::::"
		  WScript.Echo "Manufacturer: " & strManu
		  Wscript.Echo "Model: " & strModel
		  Wscript.Echo "Dell Service Tag: " & strDellTag
		  Wscript.Echo "Processor type: " & strProcessor
		  Wscript.Echo "RAM: " & strRAM
		  Wscript.Echo "Time Zone: " & strTimeZone
		  Wscript.Echo "Daylight Savings in effect: " & strDayLIghtSavings
		  Wscript.Echo "-------------------------------------------------------------"
 
		end if
		
			    
	    'flushes error code from the previous loop
	    Err.Clear
	    
		
            ' 
 
        Else
            '
	     UnavailableSystems =  strComputer & ", " & UnavailableSystems
 
	   End If
    Loop
 
	  
    objRecordSet.MoveNext
Loop
 
Wscript.Echo "The following systems were unavailable: " & UnavailableSystems 
Wscript.Echo " "
Wscript.Echo "The following systems were on, but returned an error: " & strErrorSystems    

Open in new window

0
 
chandru_solCommented:
I think it would be better if it is a vbscript rather than HTA for multiple machines

regards
Chandru
0
 
bsharathAuthor Commented:
Chandru if a vbs can do the same thing fast enough as the HTA and with all the details i have no problem.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
chandru_solCommented:
HTA is just an user interface and vbs code is integrated in it. So vbs should do the work much faster
0
 
bsharathAuthor Commented:
ok done...
0
 
chandru_solCommented:
Try this script........... for the whole domain and all machines


regards
Chandru
On error resume next
 
Const ADS_SCOPE_SUBTREE = 2
 
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
 
Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
    "Select Name, Location from 'LDAP://DC=DOMAIN,DC=local' " _
        & "Where objectClass='computer'"  
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
 
Do Until objRecordSet.EOF
    
    ' Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value
    strComputer = objRecordSet.Fields("Name").Value
    
    Set objShell = CreateObject("WScript.Shell")
    strCommand = "%comspec% /c ping -n 3 -w 1000 " & strComputer & ""
    Set objExecObject = objShell.Exec(strCommand)
 
'clears echo replies left in strText from the previous loop
strText=""
 
 
Do While Not objExecObject.StdOut.AtEndOfStream
        strText = objExecObject.StdOut.ReadAll()
        If Instr(strText, "Reply") > 0 Then
 
 
            Set objWMIService = GetObject _
                ("winmgmts:\\" & strComputer & "\root\cimv2")
 	    Set colItems = objWMIService.ExecQuery _
                ("Select * From Win32_OperatingSystem")  
	    Set colItems2 = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
           ' Wscript.Echo Err.Description
	    Set colItems3 = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
	    Set colItems4 = objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)
 
	    For Each objItem in ColItems
                strOS = objItem.Caption
	    Next
		
	    For Each objItem in colItems2
		strDellTag = objItem.SerialNumber
		strManu = objItem.Manufacturer
	    Next
 
	    For Each objItem in colitems3
	        strUserName = objItem.Username
		strModel = objItem.Model
		strRAM = objItem.TotalPhysicalMemory
		strTimeZone = (objItem.CurrentTimeZone / 60)
		strDayLightSavings = objItem.DaylightInEffect
	    Next
	
	    For Each objItem in colitems4
		strProcessor = objItem.Name
            Next
		
		If Err.Number > 0 then
		  strErrorSystems =  strComputer & ", " & strErrorSystems 
		else
		  Wscript.Echo "-------------------------------------------------------------"
		  Wscript.Echo "Computer Name: " & strComputer & ", " & strUserName
		  Wscript.Echo "-------------------------------------------------------------"
	          Wscript.Echo "Operating System: " & strOS 
                  Wscript.Echo "Current User: " & strUserName
		  Wscript.Echo "::::"
		  WScript.Echo "Manufacturer: " & strManu
		  Wscript.Echo "Model: " & strModel
		  Wscript.Echo "Dell Service Tag: " & strDellTag
		  Wscript.Echo "Processor type: " & strProcessor
		  Wscript.Echo "RAM: " & strRAM
		  Wscript.Echo "Time Zone: " & strTimeZone
		  Wscript.Echo "Daylight Savings in effect: " & strDayLIghtSavings
		  Wscript.Echo "-------------------------------------------------------------"
 
		end if
		
			    
	    'flushes error code from the previous loop
	    Err.Clear
	    
		
            ' 
 
        Else
            '
	     UnavailableSystems =  strComputer & ", " & UnavailableSystems
 
	   End If
    Loop
 
	  
    objRecordSet.MoveNext
Loop
 
Wscript.Echo "The following systems were unavailable: " & UnavailableSystems 
Wscript.Echo " "
Wscript.Echo "The following systems were on, but returned an error: " & strErrorSystems 

Open in new window

0
 
bsharathAuthor Commented:
I dont know what's happening with this script.Its running from 4 hrs.a command window flashes and goes and the wscript process is running since then.
0
 
chandru_solCommented:
It is for the whole domain. It will take time to complete.

Does it output the results or the results is empty?

regards
Chandru
0
 
bsharathAuthor Commented:
There is no file created and just now stopped the process.For 3000 machines will it take 4 hrs?
Can you make the script to get data for 1 machines as testing...
0
 
bsharathAuthor Commented:
Thanks a lot Chandru...Excellen job.... :-)
0
 
bsharathAuthor Commented:
Chandru i would be interested on the first script as well.Can you tell me if there is some thing i need to change as that scans all machines in the Domain no matter which OU they are.
0
 
chandru_solCommented:
Can i know the reason why as this script solves the purpose?
0
 
bsharathAuthor Commented:
We have different OU's and i need to change it once each time one OU is finished.If it is too difficult never mind...
0
 
chandru_solCommented:
No nothing is difficult. I think we have the option to select OU from a list file. let me check
0
All Courses

From novice to tech pro — start learning today.