
June 19th, 2012, 10:31 AM
|
|
Registered User
|
|
Join Date: Jun 2012
Posts: 2
Time spent in forums: 6 m 42 sec
Reputation Power: 0
|
|
|
Getting VBscript to work with ajax?
Hi,
I'm having problems passing a vbscript variable through ajax. Is that even possible? Is there a workaround for something like below? My idea is to grab the computer name via vbs and send it as a form to another webpage to process it. This is being housed in a jsp page.
The main issue is that while the computer name is saved to the variable msg, I don't know how to get that variable working in the second part:
objHTTP.send "field1=msg"
It of course, just sends msg rather than the computer name.
Any ideas?
<script type="text/vbscript">
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
msg = objOperatingSystem.Caption
document.write(msg)
Next
Set objHTTP = CreateObject("Microsoft.XMLHTTP")
objHTTP.open "POST", "http://localhost:8080/IQCS/SelfService/test/rectest.jsp", False
objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objHTTP.send "field1=msg"
Set objHTTP = Nothing
</script>
|