?
Solved

Output 2 items from script to 2 text boxes

Posted on 2006-07-20
4
Medium Priority
?
567 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
  • 3
4 Comments
 
LVL 17

Accepted Solution

by:
gops1 earned 1500 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

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
Suggested Courses

571 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