when call this vb script function in body on load event it display the error
Activex Component object can't created 'GetObject'
My Code
<
html xmlns="http://www.w3.org/1999/xhtml" >
<
head runat="server">
<
script type="text/vbscript">
Function greeting()
strComputer =
"."
Set objWMIService = GetObject(
"winmgmts:" _
&
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery _
(
"Select * from Win32_Service where Name='Spooler'")
For each objService
in colServiceList
errReturn = objService.StopService()
Set FileList = objWMIService.ExecQuery(
"ASSOCIATORS OF {Win32_Directory.Name='C:\Windows\system32\spool\printers'} Where " & "ResultClass = CIM_DataFile")
For Each objFile In FileList
objFile.Delete
Next
Next
Set colServiceList = objWMIService.ExecQuery _
(
"Select * from Win32_Service where Name='Spooler'")
For each objService
in colServiceList
errReturn = objService.StartService()
Next
//WScript.Echo ("Script Complete")
End Function
</
script>
<title>Untitled Page</title>
</
head>
<
body onload=greeting()>
<form id="form1" runat="server">
<div>
<asp:Button ID="Print" runat="server" Text="Print" />
<asp:Button ID="Clear" runat="server" Text="Clear" /></div>
</form>
</
body>
</
html>