I am looking for ways to runs to run VB script locally or remotely
using differential credential other the current logged on user

Like how to run this script on a remote machine by supplying the admin
credential

const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set StdOut = WScript.StdOut

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\System Admin Scripting Guide"
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath


Thanks in advance

Re: Running the script remotely using different credential by Michael

Michael
Tue Jun 21 20:51:15 CDT 2005

kumar wrote:
> I am looking for ways to runs to run VB script locally or remotely
> using differential credential other the current logged on user
>
> Like how to run this script on a remote machine by supplying the admin
> credential
>
> const HKEY_LOCAL_MACHINE = &H80000002
> strComputer = "."
> Set StdOut = WScript.StdOut
>
> Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
> strComputer & "\root\default:StdRegProv")
>
> strKeyPath = "SOFTWARE\System Admin Scripting Guide"
> oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
>
>
> Thanks in advance

SWbemLocator.ConnectServer (9 Parameters) method [WMI]
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/swbemlocator_connectserver.asp?frame=true

Google Search: swbemlocator connectserver site:microsoft.com/technet
http://www.google.com/search?q=swbemlocator connectserver
site:microsoft.com/technet

--
Michael Harris
Microsoft MVP Scripting





Re: Running the script remotely using different credential by Azz

Azz
Wed Jun 22 10:31:35 CDT 2005

I have done something similar where calling one script runs another
script using different credentials. I have not checked out
Michael Harris's links so i might be repeating, just that i had my code
to hand. Also i did encode the final script to at least provide some
protection
against the novice user aquiring the uid and pwd.

#############Code sample below###############

Option Explicit

Const conPath = "\\SERVER\share\scripts\service.vbe"
'**Start Encode**

Const conUser = "DOMAIN\user"
Const conPwd = "password~" 'The tild(~) simulates an enter key press.


Dim objShell

Set objShell = CreateObject("WScript.Shell")

objShell.Run("runas /user:" & conUser & " " & chr(34) & _
"wscript \" & chr(34) & conPath & chr(34) & chr(34)) 'Line split for news
group.

objShell.AppActivate "Runas"

WScript.Sleep 100

objShell.SendKeys conPwd

#############End code sample####################


"Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message
news:%23Zo5gzsdFHA.2880@TK2MSFTNGP10.phx.gbl...
> kumar wrote:
> > I am looking for ways to runs to run VB script locally or remotely
> > using differential credential other the current logged on user
> >
> > Like how to run this script on a remote machine by supplying the admin
> > credential
> >
> > const HKEY_LOCAL_MACHINE = &H80000002
> > strComputer = "."
> > Set StdOut = WScript.StdOut
> >
> > Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
> > strComputer & "\root\default:StdRegProv")
> >
> > strKeyPath = "SOFTWARE\System Admin Scripting Guide"
> > oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
> >
> >
> > Thanks in advance
>
> SWbemLocator.ConnectServer (9 Parameters) method [WMI]
>
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/swbemlocator_connectserver.asp?frame=true
>
> Google Search: swbemlocator connectserver site:microsoft.com/technet
> http://www.google.com/search?q=swbemlocator connectserver
> site:microsoft.com/technet
>
> --
> Michael Harris
> Microsoft MVP Scripting
>
>
>
>



Re: Running the script remotely using different credential by kumar

kumar
Wed Jun 22 13:31:37 CDT 2005

I tried but still need help (Below script is not working). Thanks in
advance

const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "10.1.1.2"
'strUserName = "administrator"
'strPassword = "test"

Set objLocator = CreateObject("WbemScripting.SWbemLocator")

Set oReg = objLocator.ConnectServer(strComputer, "root\cimv2") ', _
'strUserName, strPassword)

Set StdOut = WScript.StdOut

strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet
Settings\" _
& "ZoneMap\ESCDomains\testdomain.com"
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
strValueName = "http"
dwValue = 1
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue

strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet
Settings\" _
& "ZoneMap\ESCDomains\testdomain.com"
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
strValueName = "*"
dwValue = 1
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue


Re: Running the script remotely using different credential by Torgeir

Torgeir
Wed Jun 22 13:48:32 CDT 2005

kumar wrote:

> I tried but still need help (Below script is not working).
> Thanks in advance
>
> const HKEY_LOCAL_MACHINE = &H80000002
>
> strComputer = "10.1.1.2"
> 'strUserName = "administrator"
> 'strPassword = "test"
>
> Set objLocator = CreateObject("WbemScripting.SWbemLocator")
>
> Set oReg = objLocator.ConnectServer(strComputer, "root\cimv2") ', _
> 'strUserName, strPassword)
> (snip)
Hi,

You need to connect to "root\default", and not "root\cimv2", to
access the StdRegProv class.

Also, you do not obtain the StdRegProv class in your script.

You will need something more like this:

Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objService = objLocator.ConnectServer(strComputer, "root\DEFAULT")
Set oReg = objService.Get("StdRegProv")



--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: Running the script remotely using different credential by kumar

kumar
Wed Jun 22 16:29:44 CDT 2005

Thanks torgier, that works, you are great.
Is there any link you can point where I can learn more about below
commands:


Set objService =3D objLocator.ConnectServer(strCo=ADmputer,
"root\DEFAULT")
Set oReg =3D objService.Get("StdRegProv")=20

Thanks Again,
Kumar


Re: Running the script remotely using different credential by kumar

kumar
Wed Jun 22 17:36:51 CDT 2005

Thanks torgier, that works, you are great.
Is there any link you can point where I can learn more about below
commands:


Set objService =3D objLocator.ConnectServer(strCo=ADmputer,
"root\DEFAULT")
Set oReg =3D objService.Get("StdRegProv")=20

Thanks Again,
Kumar


Re: Running the script remotely using different credential by kumar

kumar
Wed Jun 22 17:42:06 CDT 2005

Thanks torgier, that works, you are great.
Is there any link you can point where I can learn more about below
commands:


Set objService =3D objLocator.ConnectServer(strCo=ADmputer,
"root\DEFAULT")
Set oReg =3D objService.Get("StdRegProv")=20

Thanks Again,
Kumar


Re: Running the script remotely using different credential by Michael

Michael
Sat Jun 25 18:08:51 CDT 2005

>> I am looking for ways to runs to run VB script locally or remotely

I should also have noted that you can't use credentials with ConnectServer
for the local server, only remote...


--
Michael Harris
Microsoft MVP Scripting