Is it possible for a script to install a program that runs as an administrator by default?

In vbscript or cscript or whatever, is there a way to script an install for a program so that it always runs as administrator by default?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You will most likely need to call a command line function for this. The first link shows how to do this. The second is how to use the runas command to launch your program. If the program is an msi file, run msiexec /? for more details on how to install
RichardRigaAuthor Commented:
Thanks for answering so fast.  I'll take a look at the links and get back to you.  The program is in an msi file, yes.
You can *install* it with administrative rights by running the install command as a StartUp script, which will install at computer StartUp (not user login), using the local SYSTEM account.

However, to have it *run* as an administrator, regardless of who is logged in, is not really possible unless you hard code the user credentials into a command like PSExec or CPAU.

You can configure the shorcut to "Run As Another User", but this is the same as right-clicking, and selecting Run As.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RichardRigaAuthor Commented:
So then can you add in the installation script something to configure the shortcut after its installed?
You could use the below script to create a shortcut that actually launches RunAs, and passes the arguments as the program you want to actually run.


Set objShell = CreateObject("WScript.Shell")
strDesktop = objShell.SpecialFolders("Desktop")
Set objLink = objShell.CreateShortcut(strDesktop & "\TestShortcut.lnk")
objLink.TargetPath = "%SystemRoot%\system32\runas.exe"
objLink.WindowStyle = 1
objLink.IconLocation = "notepad.exe, 0"
objLink.Description = "Shortcut Script"
objLink.WorkingDirectory = strDesktop
objLink.Arguments = " /user:%USERDOMAIN%\administrator notepad.exe"

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.