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
>
>
>
>