Solved

Output 2 items from script to 2 text boxes

Posted on 2006-07-20
4
560 Views
Last Modified: 2008-01-09
This script below is a .vbs but I would like to use javascript. Is is possible to take the information this script retreives and send that info to 2 text boxes.

On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

arrComputers = Array("SM-57-11-80")
For Each strComputer In arrComputers
   WScript.Echo
   WScript.Echo "=========================================="
   WScript.Echo "Computer: " & strComputer
   WScript.Echo "=========================================="

   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkConnection", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)

   For Each objItem In colItems
      WScript.Echo "ConnectionType: " & objItem.ConnectionType
      WScript.Echo "UserName: " & objItem.UserName
      WScript.Echo
   Next
Next


Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm:
      WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
      Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
      & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function
0
Comment
Question by:msammis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 17

Accepted Solution

by:
gops1 earned 500 total points
ID: 17145648
Give a try:


<script language="javascript">
function Puttotext(){
  document.form1.textbox.value = <%=WMIDateStringToDate%>;
}
</script>
0
 

Author Comment

by:msammis
ID: 17145914
I think you are right but I'll tell you what I am trying to acomplish and see if you can further help.
I should have provided you some better details.

I am trying to retreive some information from the "SELECT * FROM Win32_NetworkConnection", "WQL", _

      WScript.Echo "ConnectionType: " & objItem.ConnectionType
      WScript.Echo "UserName: " & objItem.UserName

I want to do this using javascript but I only have vbs code and I do not know enough javascript to rewrite the code.

I need to information to populate in a web page, 2 text boxes.

I will still try to use your first suggestion as well but if you have and idea I'd sure appreciate it !
0
 

Author Comment

by:msammis
ID: 17146074

I just need the script below in vbs script to output the items to a text area or text box in a web page.



Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

arrComputers = Array("localhost")
For Each strComputer In arrComputers

   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkConnection", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)

   For Each objItem In colItems
     
      WScript.Echo objItem.UserName
   Next
Next


Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm:
     WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
     Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
     & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function
0
 

Author Comment

by:msammis
ID: 17146085
I got an error type mismatch on the last script attempt
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

730 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