kurayami
Technical User
- Mar 12, 2008
- 31
vbscript is save in an external file called "sd.vbs"
Here is my code:
sub shutdown
strComputer = "." ' Local Computer
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}\\" & _
strComputer & "\root\cimv2")
Set colOs = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOs in colOs
objOs.Win32Shutdown(1)
Next
End Sub
-------------------
<html>
<head>
<script type="text/VBScript" src="sd.vbs"></script>
</head>
<body onload = "vbscript:shutdown">
</body>
</html>
-------------------
What I am trying to do is when the page loads the PC shuts down. The script works when I open the vbs file itself. I am having errors when loading the page.
----------
ActiveX can't create object. 'GetObject
----------
When I edit this part from:
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}\\" & _
strComputer & "\root\cimv2")
to:
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}\\" & _ strComputer & "\root\cimv2")
I get this error:
----------
type mismatch "shutdown"
----------
Anyone has a clue on what's wrong?
"A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
-Douglas Adams
Here is my code:
sub shutdown
strComputer = "." ' Local Computer
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}\\" & _
strComputer & "\root\cimv2")
Set colOs = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOs in colOs
objOs.Win32Shutdown(1)
Next
End Sub
-------------------
<html>
<head>
<script type="text/VBScript" src="sd.vbs"></script>
</head>
<body onload = "vbscript:shutdown">
</body>
</html>
-------------------
What I am trying to do is when the page loads the PC shuts down. The script works when I open the vbs file itself. I am having errors when loading the page.
----------
ActiveX can't create object. 'GetObject
----------
When I edit this part from:
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}\\" & _
strComputer & "\root\cimv2")
to:
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}\\" & _ strComputer & "\root\cimv2")
I get this error:
----------
type mismatch "shutdown"
----------
Anyone has a clue on what's wrong?
"A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
-Douglas Adams