473,322 Members | 1,408 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,322 software developers and data experts.

Vista, C#, and Regsvr32

Hello,

We are testing and tweaking some of our software to run on Vista, but it
turns out that we are having problems with one of our programs.

Here is our code:

// attempt an experiment to register an OCX object in silient mode
try
{
System.Diagnostics.Process.Start("regsvr32.exe", " /s \"" +
Environment.CurrentDirectory + "\\myTempLib.ocx\"");
}
catch (Exception exec)
{
....
}

However, this is not registering properly... it fails. I can only do this
in Vista manually if I run the CMD.exe as administrator.

Is there a different way of doing this now? Is there a call to the OS that I
can make that will bring up the confirmation dialog to the user to allow my
program to somehow register this library?

Thanks,

Rob
Jan 31 '07 #1
11 7961
Your app is either going to have to run as Administrator, or impersonate an
Administrator.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

"RobKinney1" <Ro********@discussions.microsoft.comwrote in message
news:9F**********************************@microsof t.com...
Hello,

We are testing and tweaking some of our software to run on Vista, but it
turns out that we are having problems with one of our programs.

Here is our code:

// attempt an experiment to register an OCX object in silient mode
try
{
System.Diagnostics.Process.Start("regsvr32.exe", " /s \"" +
Environment.CurrentDirectory + "\\myTempLib.ocx\"");
}
catch (Exception exec)
{
...
}

However, this is not registering properly... it fails. I can only do this
in Vista manually if I run the CMD.exe as administrator.

Is there a different way of doing this now? Is there a call to the OS that
I
can make that will bring up the confirmation dialog to the user to allow
my
program to somehow register this library?

Thanks,

Rob


Jan 31 '07 #2
"RobKinney1" <Ro********@discussions.microsoft.comwrote in message
news:9F**********************************@microsof t.com...
Hello,

We are testing and tweaking some of our software to run on Vista, but it
turns out that we are having problems with one of our programs.

Here is our code:

// attempt an experiment to register an OCX object in silient mode
try
{
System.Diagnostics.Process.Start("regsvr32.exe", " /s \"" +
Environment.CurrentDirectory + "\\myTempLib.ocx\"");
}
catch (Exception exec)
{
...
}

However, this is not registering properly... it fails. I can only do this
in Vista manually if I run the CMD.exe as administrator.

Is there a different way of doing this now? Is there a call to the OS that I
can make that will bring up the confirmation dialog to the user to allow my
program to somehow register this library?

Thanks,

Rob


Regsvr32 needs "administrative" privileges to register COM components, so you need to run
your program from a command prompt that was started with "Run As Administrator", or you have
to add an application manifest to your application. This application manifest must set the
"requestedExecutionLevel" to "requireAdministrator".
Application manifests can be added to an assembly by running mt.exe.
For more info read this:
http://msdn2.microsoft.com/en-us/library/aa480150.aspx
Willy.
Jan 31 '07 #3
Excellent Willy! Thank you. Now if only I can figure out how to do this
with ClickOnce. This is a ClickOnce app and the manifests created with
MageUI are set at full trust (there is no requireAdministrator that I can
see). I will experiment some more with manifests and see if I can figure
out how to set this. Sounds like a likely culprit. :~}

Thank you for the link to the article. I have been looking for that type of
document for some time now.

Rob

"Willy Denoyette [MVP]" wrote:
"RobKinney1" <Ro********@discussions.microsoft.comwrote in message
news:9F**********************************@microsof t.com...
Hello,

We are testing and tweaking some of our software to run on Vista, but it
turns out that we are having problems with one of our programs.

Here is our code:

// attempt an experiment to register an OCX object in silient mode
try
{
System.Diagnostics.Process.Start("regsvr32.exe", " /s \"" +
Environment.CurrentDirectory + "\\myTempLib.ocx\"");
}
catch (Exception exec)
{
...
}

However, this is not registering properly... it fails. I can only do this
in Vista manually if I run the CMD.exe as administrator.

Is there a different way of doing this now? Is there a call to the OS that I
can make that will bring up the confirmation dialog to the user to allow my
program to somehow register this library?

Thanks,

Rob


Regsvr32 needs "administrative" privileges to register COM components, so you need to run
your program from a command prompt that was started with "Run As Administrator", or you have
to add an application manifest to your application. This application manifest must set the
"requestedExecutionLevel" to "requireAdministrator".
Application manifests can be added to an assembly by running mt.exe.
For more info read this:
http://msdn2.microsoft.com/en-us/library/aa480150.aspx
Willy.
Jan 31 '07 #4
Thank you for replying Spencer. I will look into this as soon as I can. I
just have to figure out how to have the application launch as administrator
since it is a ClickOnce app....

Thanks!

Rob

"Kevin Spencer" wrote:
Your app is either going to have to run as Administrator, or impersonate an
Administrator.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

"RobKinney1" <Ro********@discussions.microsoft.comwrote in message
news:9F**********************************@microsof t.com...
Hello,

We are testing and tweaking some of our software to run on Vista, but it
turns out that we are having problems with one of our programs.

Here is our code:

// attempt an experiment to register an OCX object in silient mode
try
{
System.Diagnostics.Process.Start("regsvr32.exe", " /s \"" +
Environment.CurrentDirectory + "\\myTempLib.ocx\"");
}
catch (Exception exec)
{
...
}

However, this is not registering properly... it fails. I can only do this
in Vista manually if I run the CMD.exe as administrator.

Is there a different way of doing this now? Is there a call to the OS that
I
can make that will bring up the confirmation dialog to the user to allow
my
program to somehow register this library?

Thanks,

Rob


Jan 31 '07 #5
"RobKinney1" <Ro********@discussions.microsoft.comwrote in message
news:5E**********************************@microsof t.com...
Excellent Willy! Thank you. Now if only I can figure out how to do this
with ClickOnce. This is a ClickOnce app and the manifests created with
MageUI are set at full trust (there is no requireAdministrator that I can
see). I will experiment some more with manifests and see if I can figure
out how to set this. Sounds like a likely culprit. :~}

Thank you for the link to the article. I have been looking for that type of
document for some time now.
Rob,

Before you start experimenting, you should definitely read this:

http://www.microsoft.com/downloads/d...displaylang=en
Willy.

Feb 1 '07 #6
Both excellent references. I have had Vista on my home machine for a few
weeks now, and have been wanting to find such guidelines, as it is clear
that certain types of applications will need special priveleges. I have
tried a few of my .Net 2.0 apps on that machine, and they run fine, but they
don't try to do anything that requires Administrative privelege, or access
to the registry. These 2 docs are now in my Favorites and Documents. Thanks
Willy!

--

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:OL**************@TK2MSFTNGP04.phx.gbl...
"RobKinney1" <Ro********@discussions.microsoft.comwrote in message
news:5E**********************************@microsof t.com...
>Excellent Willy! Thank you. Now if only I can figure out how to do this
with ClickOnce. This is a ClickOnce app and the manifests created with
MageUI are set at full trust (there is no requireAdministrator that I can
see). I will experiment some more with manifests and see if I can
figure
out how to set this. Sounds like a likely culprit. :~}

Thank you for the link to the article. I have been looking for that type
of
document for some time now.

Rob,

Before you start experimenting, you should definitely read this:

http://www.microsoft.com/downloads/d...displaylang=en
Willy.

Feb 1 '07 #7
Hi Rob,

The following article may be of some help:

http://msdn2.microsoft.com/en-us/lib...xw(VS.80).aspx

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

"RobKinney1" <Ro********@discussions.microsoft.comwrote in message
news:F6**********************************@microsof t.com...
Thank you for replying Spencer. I will look into this as soon as I can.
I
just have to figure out how to have the application launch as
administrator
since it is a ClickOnce app....

Thanks!

Rob

"Kevin Spencer" wrote:
>Your app is either going to have to run as Administrator, or impersonate
an
Administrator.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

"RobKinney1" <Ro********@discussions.microsoft.comwrote in message
news:9F**********************************@microso ft.com...
Hello,

We are testing and tweaking some of our software to run on Vista, but
it
turns out that we are having problems with one of our programs.

Here is our code:

// attempt an experiment to register an OCX object in silient mode
try
{
System.Diagnostics.Process.Start("regsvr32.exe", " /s \"" +
Environment.CurrentDirectory + "\\myTempLib.ocx\"");
}
catch (Exception exec)
{
...
}

However, this is not registering properly... it fails. I can only do
this
in Vista manually if I run the CMD.exe as administrator.

Is there a different way of doing this now? Is there a call to the OS
that
I
can make that will bring up the confirmation dialog to the user to
allow
my
program to somehow register this library?

Thanks,

Rob




Feb 1 '07 #8
"Kevin Spencer" <un**********@nothinks.comwrote in message
news:e2**************@TK2MSFTNGP04.phx.gbl...
Both excellent references. I have had Vista on my home machine for a few weeks now, and
have been wanting to find such guidelines, as it is clear that certain types of
applications will need special priveleges. I have tried a few of my .Net 2.0 apps on that
machine, and they run fine, but they don't try to do anything that requires Administrative
privelege, or access to the registry. These 2 docs are now in my Favorites and Documents.
Thanks Willy!
Sure they are, it's a pity they are so hard to find while they are a "must read" for every
Windows developer.

Willy.
Feb 1 '07 #9
Hello Willy,

I have been at this all day today... We have been trying to insert the code
<requestedPrivileges>
<requestedExecutionLevel
level="requireAdministrator"
uiAccess="false"/>
</requestedPrivileges>

in our application manifest but we keep getting errors like:

The element 'PermissionSet' in namespace 'urn:schemas-microsoft-com:asm.v2'
has invalid child element 'requestedExecutionLevel' in namespace
'urn:schemas-microsoft-com:asm.v2'. List of possible elements expected:
'IPermission, Permission' in namespace 'urn:schemas-microsoft-com:asm.v2' as
well as any element in namespace '##other'.

We have tried to add the requireAdministrator level everywhere possible in
the security tag and cannot get the application to launch.

...... I then quested to use the RUNAS command in the shell command to run
reg32... no luck.

Then I went and tried running/calling DllRegisterServer in my code... --
that works only if I right click on the executable (this was a small local
test to see if I could get the library to register or at least bring up the
UAC box) and tell it to run as Administrator.

Any other ideas? Am I missing something simple? I am combing the net and
have found about 4 other people that have extremely similar problems, but
they never posted a resolution.

Thanks again for your time.

Rob

"Willy Denoyette [MVP]" wrote:
>
Sure they are, it's a pity they are so hard to find while they are a "must read" for every
Windows developer.

Willy.
Feb 1 '07 #10
"RobKinney1" <Ro********@discussions.microsoft.comwrote in message
news:70**********************************@microsof t.com...
Hello Willy,

I have been at this all day today... We have been trying to insert the code
<requestedPrivileges>
<requestedExecutionLevel
level="requireAdministrator"
uiAccess="false"/>
</requestedPrivileges>

in our application manifest but we keep getting errors like:

The element 'PermissionSet' in namespace 'urn:schemas-microsoft-com:asm.v2'
has invalid child element 'requestedExecutionLevel' in namespace
'urn:schemas-microsoft-com:asm.v2'. List of possible elements expected:
'IPermission, Permission' in namespace 'urn:schemas-microsoft-com:asm.v2' as
well as any element in namespace '##other'.

We have tried to add the requireAdministrator level everywhere possible in
the security tag and cannot get the application to launch.
The assembly manifest should look something like :

<?xml version="1.0" encoding="utf-8" ?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0"
processorArchitecture="X86"
name="xxxxxxxxxxx"
type="win32" />
<description>yyyyyyyyyyyyyyy</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

Where xxxxxxxx is the executable name (fi. killerapp) and yyyyyyy some application
description.
Inserting the manifest in the assembly goes with:

mt -manifest <manifestfilename-outputresource:killerapp.exe;#1
..... I then quested to use the RUNAS command in the shell command to run
reg32... no luck.
You have to start the shell with "Run As Adminsistrator"....
Willy.

Feb 1 '07 #11
Willy,

We are so close!... well, at least I think we are.

We finally were able to understand the concept of embedding the manifest you
provided for us as part of the executable. And in fact when I look at the
exe icon, it now has a little shield in the lower right-hand corner.

We can launch the program locally and it works great! It brings up the UAC
box and asks if the user wants to continue... and when it does, the
application loads perfectly.

However, we cannot get it to work with the ClickOnce deployment. Every
time we try to use the exe with the embedded manifest, we get the following
error:

Reference in the manifest does not match the identity of the downloaded
assembly [ourApp.exe].

We did some searching on the net but still cannot find the solution. When
we do not use the exe with the embedded manifest, the project downloads and
starts up fine (although the library is not able to load and the program soon
crashes as was the original problem).

Do you know if there is a problem using an embedded manifest in the exe
while deploying through ClickOnce? If so, is there a workaround?

Thanks again Willy. We really appreciate the help :~}

Rob
"Willy Denoyette [MVP]" wrote:
"RobKinney1" <Ro********@discussions.microsoft.comwrote in message
news:70**********************************@microsof t.com...
Hello Willy,

I have been at this all day today... We have been trying to insert the code
<requestedPrivileges>
<requestedExecutionLevel
level="requireAdministrator"
uiAccess="false"/>
</requestedPrivileges>

in our application manifest but we keep getting errors like:

The element 'PermissionSet' in namespace 'urn:schemas-microsoft-com:asm.v2'
has invalid child element 'requestedExecutionLevel' in namespace
'urn:schemas-microsoft-com:asm.v2'. List of possible elements expected:
'IPermission, Permission' in namespace 'urn:schemas-microsoft-com:asm.v2' as
well as any element in namespace '##other'.

We have tried to add the requireAdministrator level everywhere possible in
the security tag and cannot get the application to launch.

The assembly manifest should look something like :

<?xml version="1.0" encoding="utf-8" ?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0"
processorArchitecture="X86"
name="xxxxxxxxxxx"
type="win32" />
<description>yyyyyyyyyyyyyyy</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

Where xxxxxxxx is the executable name (fi. killerapp) and yyyyyyy some application
description.
Inserting the manifest in the assembly goes with:

mt -manifest <manifestfilename-outputresource:killerapp.exe;#1
..... I then quested to use the RUNAS command in the shell command to run
reg32... no luck.

You have to start the shell with "Run As Adminsistrator"....
Willy.
Feb 2 '07 #12

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

Similar topics

2
by: Sahil Malik | last post by:
Fairly simple question !!! The title says it all. But here is a further description - I have a software that expects a COM DLL. Due to certain requirements we have to create a .NET assembly...
5
by: vovan | last post by:
My VB6 application uses DLL developed in VB2005. It may be changed very often and everytime VB6 application unregisters an old version, replaces with a new one and registers a new version by using...
0
by: Ian Toltz | last post by:
Is anyone using System.DirectoryServices successfully in an application on Vista? Using this amazing article ( http://www.codeproject.com/useritems/everythingInAD.asp ) I've been working on...
0
by: John Kotuby | last post by:
Hi all... Anyone know if multisite.dll works in Vista? I tried using regsvr32 to register it but Vista said it couldnt find an entry point. Yes, it's the 32 bit version of Vista ultimate and I ran...
3
by: Johnson | last post by:
I installed VisualBasic6 on Vista, I tried to open it, but vb pop-up a window, it said "MSVBVM60.DLL" can't register, how can I do. P.S 1.My vista is Vista Ultimate (Traditional Chinese). 2.The...
2
by: luttkens | last post by:
I want to register a DLL (fastreport3.dll (version 4.4, size 2 400 kB)) on Windows Vista using regsvr32. It works on Windows XP, but not on Vista. I have tried to do it as administrator and I have...
5
by: Geoff Blood | last post by:
Using Visual Studio 2005 I have VB project that produces a program that is to be deployed using a VS2005 deployment project. There are some legacy COM components that need to be registered with...
2
by: timmg | last post by:
Situation: Single .mdb developed in A97 last Centurary, very stable and minimal enhancements in the last 3 years. Previously converted to A2000 Test conversion to 2007 on Vista works except...
0
Fary4u
by: Fary4u | last post by:
I'm trying to run a program that runs fine on XP OS, but it won't run on Vista. I've tried to install msinet.ocx in the system32 folder, but it never works. I've tried to register with regsvr32...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.