I'm presenting the output of my VBScript in an HTML page. What I'd like to do is place a button at the bottom of this page which executes the same script again. I'm trying the form button (see bottom of the script below) but not having any luck - nothing happens)
Can anyone help?
Can anyone help?
Code:
Const ADS_SCOPE_SUBTREE = 2
Dim objRootDSE, objUser, objFSO, objShell, strDate, strTime, strLogFileName, strDNSname, objUsrCommand, objUsrConnection, objUsrRecordSet
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Wscript.Shell")
Set objExplorer = CreateObject("InternetExplorer.Application")
objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width= 800
objExplorer.Height = 480
objExplorer.Left = 0
objExplorer.Top = 0
objExplorer.Visible = 1
objExplorer.Document.BGColor="#808080"
objExplorer.Document.FGColor="#FFFFFF"
strInner = "<font face=""Arial""><U><Centre><B>Commencing " & wscript.scriptname & "</B></U></centre></P></P>"
UpdateProgress
strInner = strInner & "Get all users script - Commencing run at " & Time & " on " & Date & ".</p>"
strInner = strInner & "Records will be read from the " & strDNSDomain & " domain.</p>"
Set objUsrCommand = CreateObject("ADODB.Command")
Set objUsrConnection = CreateObject("ADODB.Connection")
objUsrConnection.Provider = "ADsDSOObject"
objUsrConnection.Open "Active Directory Provider"
objUsrCommand.ActiveConnection = objUsrConnection
objUsrCommand.CommandText = _
"SELECT adsPath FROM 'LDAP://" & strDNSDomain & "' " _
& "WHERE objectClass = 'User'"
objUsrCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objUsrCommand.Properties("Page Size") = 1000
objUsrCommand.Properties("Timeout") = 30
objUsrCommand.Properties("Cache Results") = True
Set objUsrRecordSet = objUsrCommand.Execute
Do Until objUsrRecordSet.EOF
For each oField in objUsrRecordSet.Fields
set objUser = GetObject(oField.value)
objUser.getinfo
strUsername = objUser.samaccountname
if instr(1,strUserName,"$",0) > 0 then
exit for
else
strInner = strInner & strUsername & "</br>"
UpdateProgress
end if
Next
objUsrRecordSet.MoveNext
Loop
strInner = strInner & "<FORM NAME=""Form1"">"
strInner = strInner & "<INPUT TYPE=""Button"" NAME=""Button1"" VALUE=""Run Again"">"
strInner = strInner & "<SCRIPT FOR=""Button1"" EVENT=""onClick"" LANGUAGE=""VBScript"">"
strInner = strInner & "Set objShell = CreateObject(""Wscript.Shell"")"
strInner = strInner & "objShell.Run wscript.scriptfullname , 0, True"
strInner = strInner & "</SCRIPT>"
UpdateProgress
objUsrConnection.Close
Set objUsrCommand = Nothing
Set objUsrConnection = Nothing
Set objUsrRecordSet = Nothing
wscript.quit(0)
Function UpdateProgress
with objExplorer.Document
.body.InnerHTML = strInner
.parentwindow.scrollTo 0,.body.scrollHeight
end with
End Function