Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VBScript runtime error Permission Denied GetObject

792 views
Skip to first unread message

Steven Wing

unread,
Nov 16, 2004, 7:30:00 AM11/16/04
to
Hello all,

I am going to be crazy about that. I run the following code on XP Sp1 box,
if the strComputer=".", everything is fine. If I switch to remote computer,
it failed and return error "C:\Script\test.vbs(10, 1) Microsoft VBScript
runtime error: Permission denied: 'GetObject'", of course i use Domain Admin
accounts to run this script.

Option Explicit

Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_CURRENT_USER = &H80000001

Dim strComputer, strKeyPath, strValueName, objRegistry, strValue

strComputer = "RemoteServer"
'strComputer = "."
Set objRegistry=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
strComputer & "\root\default:StdRegProv")

strKeyPath = "SYSTEM\CurrentControlSet\Services\lanmanserver\parameters"
strValueName = "AutoShareServer"
objRegistry.GetDWORDValue
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

If IsNull(strValue) Then
Wscript.Echo "The registry key does not exist."
Else
Wscript.Echo "The registry key exists."
End If
===========================
But the problem is when copy the file to other XP SP1 box, it works like a
charm. I do install the latest Windows Script 5.6 version on it, what's
wrong with the problem?

Many thanks for your time!


Richard Mueller [MVP]

unread,
Nov 17, 2004, 6:58:11 PM11/17/04
to
Steven Wing wrote:

Hi,

WMI is required on both machines, the one running the script and the remote
computer. Also, DCOM must not be disabled. Both machines should be joined to
the domain, and you need administrator rights (generally, you should be a
member of the "Domain Admins" group, which should have admin rights on all
computers in the domain). On some networks, DCOM has been disabled to
prevent worms. WMI comes with Windows 2000 or above, and can be installed on
older clients.

--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--


Steven Wing

unread,
Nov 18, 2004, 3:26:55 AM11/18/04
to
you made it, richard!

After I enabled DCOM on my XP, it works on my box. Cheers!

"Richard Mueller [MVP]" <rlmuelle...@ameritech.NOSPAM.net> wrote in
message news:eWE7YFQz...@tk2msftngp13.phx.gbl...

0 new messages