February 07, 2007

Installing ClickOnce application as non–admin user

Insight shipped a while ago. It is deployed as a ClickOnce application. The bootstrap setup.exe created by the .NET SDK is excellent in that it detects missing pre-requisites on a user’s machine, downloads and installs them.
The problem is that a non-admin user will not be able to install components such as the .NET Framework, Microsoft Reporting Library, etc.
“Right-click, RunAs admin” on the setup.exe works except that the Start Menu entry for the application is put in the Administrator’s start menu and home directory. This means the user has to run Setup.exe again as themself! Argh, imagine the support calls on that one…

My solution is to make a ZIP file containing setup.exe, Install.bat and part2.bat.
Install.bat contains:

@echo off
set _User_=%USERDOMAIN%%USERNAME%
set _wd_=%CD%

echo Installing Insight for %_User_%.
runas /u:%COMPUTERNAME%\Administrator "cmd.exe /c CD \"%_wd_%\" && part2.bat \"%_User_%\" \"%_wd_%\""

which upon running prompts:

Installing Insight for WORK\Andrew Davey.
Enter the password for WORK\Administrator: 

The user types the admin password, hits enter. That runs part2.bat:

@echo off
echo Giving %1 temporary Administrator status
net localgroup Administrators %1 /ADD
echo Running Insight install program
runas /u:%1 "cmd.exe /c CD %CD% && setup.exe" 
echo Removing %1's Administrator status
net localgroup Administrators %1 /DELETE

That adds the user to the Administrator group, then runs setup.exe as the user (but now with admin permissions). Afterwards, the user is removed from the Administrator group.

I took the idea from the MakeMeAdmin.cmd batch file. I could not seem to pass the current directory using MakeMeAdmin, so it could not find setup.exe. That’s why I have two batch files.
Maybe someone can point out how it should be done.

So the result is I can tell someone to download the ZIP, extract and double-click Install.bat. Whilst that’s not exactly “ClickOnce” anymore, it slightly better than the alternative! Of course once installed, any later application updates go into the user’s directory so no admin permissions are required.
I hope Microsoft update the bootstrapper in the next version so that it can handle non-admin users better.


- No comments Not publicly viewable


Add a comment

You are not allowed to comment on this entry as it has restricted commenting permissions.

Trackbacks

Google Ads

Search this blog

Most recent comments

  • I scratched my eye while i was holding some kind of plastic packaging.. Anyways the corner of the pl… by Ercan on this entry
  • About a year ago my contacts that i was wearing, i guess were fautly, because shortly after they wer… by Jon on this entry
  • I got shower gel in my eye 4 and a half days ago, and becasue i rubbed my eyes a lot, i have scratch… by Chris on this entry
  • This website may help http://www.webmd.com/eye–health/tc/Eye–Injuries–Home–Treatment by S on this entry
  • I somehow got dirt, or debris in my eye. The terrible pain sent me in a tailspin. I was afraid of sa… by Bobbi on this entry

Tags

February 2007

Mo Tu We Th Fr Sa Su
Jan |  Today  | Mar
         1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28            

Galleries

Blog archive

Loading…
Not signed in
Sign in

Powered by BlogBuilder
© MMXIV