"sunil" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
>>
>> You should ask the user to 1) logoff form it's current logon session and 2) to logon as
>> an
>> admin , asking a user for an admin password doesn't make him run as an admin. You should
>> do
>> this as soon as you can in your code and yes you can use a Messagebox for this.
>>
>> Willy.
>
> Dear Willy,
> i had tried out what you have suggested, but I had lot of problems. The
> code that I added is:
>
> public override void Install(System.Collections.IDictionary stateSaver)
> {
> WindowsPrincipal wp = new
> WindowsPrincipal(WindowsIdentity.GetCurrent());
> if (!wp.IsInRole(WindowsBuiltInRole.Administrator))
> {
> MessageBox.Show("Please login with administrator privileges to
> install this product");
> throw new InstallException("Error in the installation....login with
> administrator privileges");
> }
> else
> {
> base.Install(stateSaver);
> }
> }
>
>
> After the custom messages by me using InstallException are shown, there
> is one more exception thrown
> The exception message is :
> "The savedState dictionary does not contain
> the expected values and might have been corrupted".
>
> Is there a better way to rollback the installation without other
> exceptions being thrown. Please help me with this problem!!!!
>
> One more question:
> Is there a better way to stop the installation if the currently logged
> in user is not an admin. Also, I
> want to cancel the installation, even before the choice for the
> installation folder is asked
> Is this possible?
>
As I told you, you should check this before you even start the installation, I don't know
how your setup looks like, but before you ask for the install folder (who creates this
folder btw?), you should check whether you are running as an admin.
Willy.
|