'Run As' allows user to run or execute a file with the context of another user specially it is called as run as admin. This is often important for a limited right users to run a executable file with administrator right. Another important feature of this file is to provide power the executable file to run it with One-Click. The VB Script is as follows:
-------------------Run-as-Admin.vbs-----------------------'Bismillahir Rahmanir Rahim
'This is a SCRIPT for limited user to run a PROGRAM which required ADMIN right. In other word this 'script let users run a application on be half of another user.
'Code for Computing Relative Path.
Dim RPATH
Dim aRPATH
Set fso = CreateObject("Scripting.FileSystemObject")
RPATH = fso.GetParentFolderName(wscript.ScriptFullName)
'Setup Files required in the followng line.
aRPATH = RPATH & "\some-setup-files-here"
'Code for requesting a program to run as ADMIN
Dim oShell
set oShell= Wscript.CreateObject("WScript.Shell")
'Put desire user name in the following line
oShell.Run "runas /noprofile /user:administrator "& Chr(34) _
& aRPATH & Chr(34)
WScript.Sleep 100
'ADMIN PASSWORD/user password required in the following line.
oShell.Sendkeys "admin-password-here~"
Wscript.Quit
'Note that the execiutable file & this VB Script need to remain in same directory.
------------------------Script End----------------------------
Now next part would be to encode the VBS code to VBE to secure the from viewing. For this MS Script Encoder might help & this script encoder only works up to Windows XP. I think the following link might be helpful to go ahead if someone fell interest on it...
http://xinn.org/RunasVBS.html
No comments:
Post a Comment