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?
LVL 1
RichardRigaAsked:
Who is Participating?
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.

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

http://www.techrepublic.com/forum/questions/101-300905

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/runas.mspx?mfr=true
0
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.
0
RobSampsonCommented:
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.

Regards,

Rob.
0

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?
0
RobSampsonCommented:
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.

Regards,

Rob.
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"
objLink.Save

Open in new window

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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.