03-30-2011, 09:05 AM
Hi ,
Use the below Code,
Use the below Code,
Code:
Dim objShell, objNetwork
Dim domain, program, domainUser
Set objShell = CreateObject("WScript.Shell")
Set objNetwork = WScript.CreateObject("WScript.Network")
domain = objNetwork.ComputerName
program = "notepad.exe"
domainUser = getUserName
WScript.Sleep 1000
runAsDomainUser domain, domainUser, program
Function runAsDomainUser(fxDom, fxUser, fxProgram)
MsgBox "runas /env /user:" & fxDom & "\" & fxUser & " " & Chr(34) & fxProgram & Chr(34) & "",0,"This is what is being passed to RUNAS"
objShell.Run "runas /env /user:" & fxDom & "\" & fxUser & " " & Chr(34) & fxProgram & Chr(34) & "",1,False
End Function
Function getUserName
getUserName = InputBox("Enter your Domain or Local Computer UserName")
If getUserName = "" Then
WScript.Quit
End If
End Function