Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get a script to run on webpage 1

Status
Not open for further replies.

dukkse

Technical User
Oct 15, 2003
42
US
Hey!!

I have this VB Script that works perfect as a VBscript. Now, I want this to be as an webpage so when you go to this page, it runs the script and gives the result (all servers in a specific ou in AD). I guess I have to make an ASP of this, and it's more or less just the "echo":ing that needs to change, but I get wscript error. Please help.

Heres the code

-----------------------------------------------------------
<SCRIPT LANGUAGE="VBScript">
<!--

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=phi,DC=ikea,DC=com' " _
& "where objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
If inStr(objRecordSet.Fields("Name").Value,"-NT") Then Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value
objRecordSet.MoveNext
Loop

'-->
</SCRIPT>
--------------------------------------------------------

/Daniel
 
What about replacing Wscript.Echo by MsgBox ?
You may also consider to play with DHTML populating a DIV section.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Hey!!

It worked fine with MsgBox instead, but I need it as a list in the page, so I can print it, or cut and past and so on..
Thanks so far
 
When I need this sort of thing, I put a <p> id=txtTextHere</p> tag in the body of the page. Then I can change txtTextHere.INNERText to display the results.
 
Hmm, Alright Tom, could you please add that into the script. I don't get it to work properly..
Thanks
 
Since you want a list of names, I assume you would want each one on its own line. Formatted text is easier in HTML so I would use .InnerHtml instead of .InnerText, but here's an untested sample. Let me know if it doesn't work. You'll need ato add this to the Html Body:
Code:
<p id=pTxt></p>
Then try this script:
Code:
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=phi,DC=ikea,DC=com' " _
        & "where objectClass='computer'"  
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30 
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
objCommand.Properties("Cache Results") = False 
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
strHtml = ""
Do Until objRecordSet.EOF
    If inStr(objRecordSet.Fields("Name").Value,"-NT") Then strHtml = strHtml & "Computer Name: " & objRecordSet.Fields("Name").Value & "<br>"
    objRecordSet.MoveNext
Loop
pTxt.InnerHtml = strHtml
 
Thanks Tom. Worked great...

/Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top