473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem with visual studio setup project

Hi,
I have created a setup project which installs a Network service. In the
installer, I had to set some security permissions so that Network
service can access my installation folder. Since, only administrators
can change the access list, I need to specify that admin privileges are
required to run the installer.

Is there a way to ask for admin password(if he is not an admin), find
out whether the account is valid, and exit if it is invalid, else
continue the installation.
Is there a way to do all this from the project installer.

Thanks in advance.

Jan 16 '07 #1
7 8002
"sunil" <sa**********@gmail.comwrote in message
news:11**********************@l53g2000cwa.googlegr oups.com...
Hi,
I have created a setup project which installs a Network service. In the
installer, I had to set some security permissions so that Network
service can access my installation folder. Since, only administrators
can change the access list, I need to specify that admin privileges are
required to run the installer.

Is there a way to ask for admin password(if he is not an admin), find
out whether the account is valid, and exit if it is invalid, else
continue the installation.
Is there a way to do all this from the project installer.

Thanks in advance.


WindowsPrincipal wp = new WindowsPrincipal(WindowsIdentity.GetCurrent());
if(!wp.IsInRole("BUILTIN\\" + "Administrators")))
// not an admin, tell user to logon as admin and restart install
...
else
// current user is an admin, continue install...

Willy.


Jan 16 '07 #2
"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:%2***************@TK2MSFTNGP04.phx.gbl...
"sunil" <sa**********@gmail.comwrote in message
news:11**********************@l53g2000cwa.googlegr oups.com...
>Hi,
I have created a setup project which installs a Network service. In the
installer, I had to set some security permissions so that Network
service can access my installation folder. Since, only administrators
can change the access list, I need to specify that admin privileges are
required to run the installer.

Is there a way to ask for admin password(if he is not an admin), find
out whether the account is valid, and exit if it is invalid, else
continue the installation.
Is there a way to do all this from the project installer.

Thanks in advance.

WindowsPrincipal wp = new WindowsPrincipal(WindowsIdentity.GetCurrent());
if(!wp.IsInRole("BUILTIN\\" + "Administrators")))
// not an admin, tell user to logon as admin and restart install
...
else
// current user is an admin, continue install...

Willy.


Actually one should prefer the locale friendly version of IsInRole....

if(!wp.IsInRole(WindowsBuiltInRole.Administrator))
.....

Willy.
Jan 16 '07 #3

WindowsPrincipal wp = new WindowsPrincipal(WindowsIdentity.GetCurrent());
if(!wp.IsInRole("BUILTIN\\" + "Administrators")))
// not an admin, tell user to logon as admin and restart install
...
else
// current user is an admin, continue install...

Willy.
>

Actually one should prefer the locale friendly version of IsInRole....

if(!wp.IsInRole(WindowsBuiltInRole.Administrator))
.....

Willy.
Dear Willy,
Thanks for the response. Where should I add this code? Should I add in
the InitializeComponent() method of the ProjectInstaller.cs.
// not an admin, tell user to logon as admin and restart install
How exactly should I tell user to logon as admin(can I use a dialog box
that takes admin account name and the password and check its validity)

I want to ask for the administrator password(if he is not) as soon as
the user starts the installer(before asking for the installation folder)

Jan 17 '07 #4
"sunil" <sa**********@gmail.comwrote in message
news:11**********************@l53g2000cwa.googlegr oups.com...
>
WindowsPrincipal wp = new WindowsPrincipal(WindowsIdentity.GetCurrent());
if(!wp.IsInRole("BUILTIN\\" + "Administrators")))
// not an admin, tell user to logon as admin and restart install
...
else
// current user is an admin, continue install...

Willy.
>>

Actually one should prefer the locale friendly version of IsInRole....

if(!wp.IsInRole(WindowsBuiltInRole.Administrator) )
.....

Willy.

Dear Willy,
Thanks for the response. Where should I add this code? Should I add in
the InitializeComponent() method of the ProjectInstaller.cs.
// not an admin, tell user to logon as admin and restart install
How exactly should I tell user to logon as admin(can I use a dialog box
that takes admin account name and the password and check its validity)

I want to ask for the administrator password(if he is not) as soon as
the user starts the installer(before asking for the installation folder)

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.


Jan 17 '07 #5
>
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 cancel the installation.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?

Jan 18 '07 #6
>
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?

Jan 18 '07 #7
"sunil" <sa**********@gmail.comwrote in message
news:11**********************@38g2000cwa.googlegro ups.com...
>
>>
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.

Jan 18 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Martin Bless | last post by:
The good news: Along with Python-2.4 comes really good news to Windows users. Yes, you now CAN build extension modules yourself using the SAME C++ compiler and linker Python is built with...
2
by: Wendy Elizabeth | last post by:
I was just assigned a project at work to setup a CRM web system. However from what I have heard Visual Studio 2005 Team System is suppose to be a CRM system. Is it a metholodologythat Microsoft...
2
by: Fie Fie Niles | last post by:
I have a WinXP Professional that had Microsoft Visual Studio .NET 2002. I created a new project of type Visual Basic Projects and used template: ASP.NET Web application. When I hit F5 to run the...
3
by: Richard L Rosenheim | last post by:
I have an application that works, which is written in VB using Visual Studio 2003. Now, I'm trying to create a setup application for it. As the application uses Crystal Reports, I followed the...
0
by: Husam | last post by:
Hi EveryBody: I read the articl "using Visual Studio Net 2003 to redistrbuted the Net framework" which is in the msdn library and I applied every step in it to add the Net framework to the...
13
by: Lee Newson | last post by:
Hi, I have just written my first application using VB.NET. The app works fine when i am running it within .NET for debugging purposes, however when i try to run the app from the .exe file that...
0
by: hudak | last post by:
Hi! Building a Visual Studio 2003 Setup project I got an error as follow C:\temp\Setup1\Setup1.vdproj Unable to import merge module 'CrystalReports11_5_NET'. I have added the KeyCode value for...
1
by: goose28 | last post by:
Instructions for creating a silent install project in Visual Studio.NET 2003 for "All Users". 1) Create a default setup project for your application using Visual Studio (File/New/Setup and...
0
by: adeebraza | last post by:
My Dear, Salman1karim As you have finished your first project in vb6, MS Access 2003 and crystal reports 11 and you want to create setup file. You need Pdcmdln.EXE file to create setup program of...
6
by: Author | last post by:
I have VS 2005 professional. Here is the version info: Microsoft Visual Studio 2005 Version 8.0.50727.762 (SP .050727-7600) &copy; 2005 Microsoft Corporation. All rights reserved. When I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.