I've developed a VSPackage for Visual Studio, which needs to copy some files to Visual Studio's Installation Path.
If I Run Visual Studio as Administrator (when using my installed VSPackage). It can copy files with no errors.
When I run Visual Studio normally, I get Access to the path ... is denied error.
Question
How can I give my VSPackage to admin privileges even when the Visual Studio is being run as a normal user.
Or at least how can I invoke something like this:
Your package is a .dll (loaded on a process), not an .exe (a process), and therefore it cannot have different privileges than its process (Visual Studio, that is, devenv.exe). What your package can do is to launch a different process with admin rights. See my article:
HOWTO: Launch a process with admin rights from a Visual Studio add-in on Windows Vista or higher.
That said, it is a very wrong approach to do this to copy files to the VS installation path. That should be done by the setup of your package (.msi), not by your package.
On the one hand, if it is done by the package once installed, the user could deny the elevation prompt and the files would not be copied and your installation would be incomplete. Can your package run properly without those files?
On the other hand, if the user denies the elevation prompt to install the package, it wouldn't be installed at all, which is a more clean approach.
Related
I'm trying to add Visual installer project (setup ) to my project and I have a little troubels with this. I'm using Visual Studio 2017. After installation my application don't open until i start app with admin rights, it's need only once, next running don't need admin permissions and everything works ok.
I have VS community edition and I can't find my installed files. I go to the properties window of my start up project and click down to Publish. My publishing folder location is j:\projectinstall. My installation folder is \c\program files (x86)\TestProject\ (For some reason, VS doesn't allow destinations such as c:\program files (x86)) I run publish then run the install on another workstation. Everything works fine -- I get a shortcut on the desktop and I double click it and the file runs. The problem is that it's like the files don't exist. I can't find file location, there is no target. I do a search on my hard drive and the files are just not there. Any help would be greatly appreciated. I tried it with VS 2015 and 2017.
I found the file under c:\users..\appdata\localapps... but I don't want it published into some buried folder. Please help.
The problem is that the VS Community Edition doesn't come with the proper tools to make an installer. I found a free installer program online: Inno Setup
I am trying to change the default installation directory of my projects when I publish them but I seem to have no choice over where the published setup.exe actually puts the program. It seems after setup.exe running and application installed, all the processed files are under the folder of C:\Users\{username}\AppData\Local\Apps\2.0\ (Something like that, I dont remember the exact directory as it is very long). This is not what i want as I installed the program in the C:\Program Files\ but all the log files go to the C:\Users\{username}\AppData\Local\Apps\2.0\. This is really really annoying.
The application I published is C# Windows Form Application
And I have looked through online and found that somebody suggested to create an MSI package for C# Windows Application Using a Visual Studio Setup Project instead of publishing the program:
Publish Windows form application how change the installation path
It is supposed that the above website can solve this problem. Are there any other suggestions to solve this redirection problem after publishing the C# Windows Form Application? Thank you.
When you use the Publish funtion in Visual Studio, you are creating click-once publication. This type of deployment has relatively fixed rules and not everything can be configured. It allways installs into an obfuscated folder under windows user profile. It is similar to the fact, that you cannot change location where windows-store modern apps are installed under Windows 8.1.
You can create MSI setup project for your app - but in Visual Studio 2012 this type of project is missing and it was re-introduced againg in Visuals Studio 2013. There you can specify install folder. You can also use Install Shield Lite with Visual Studio 2012.
You wrote:
This is not what i want as I installed the program in the C:\Program
Files\
It is not possible to install ClickOnce application using Publish button in Visual Studio into C:\Program Files\.
If you have just problem with the location of your log files, you need to specify a different folder within your application code. Make sure that user, who is running your app, has write access to that folder - it should be in some user's profile folder or in a public folder. Avoid %ProgramFiles% as a folder for your log files - it is not a good practice.
Instead of Application.StartupPath you should use path accessible to all users including non-admin, like:
Path.Combine(Environment.GetFolderPath(SpecialFolder.CommonApplicationData),"MyCompanyName")
You can use InstallShield to create installation wizards/Setup.
Here's the free version for Visual Studio
I have a C# project written using Visual Studio Express 2013 for Windows Desktop. When I run the project in debug mode via Visual Studio (on Windows 8 Pro) it executes just fine, and so does copying the files out of the bin directory.
I need to deploy to a Windows 7 Embedded System with the correct version of .NET Framework. I tried:
copying the files over with the .dll and everythig from the bin folder and when starting I get no error, but doesn't start at all. I get no information at all.
tried the one click installer (choosing the option to install from dvd) and it seemed to install fine, but when I start it, I get same issue. Not starting, and no messages.
I also tried the Advanced Installer (free version) and when importing the visual studio project files it fails with the message "Failed to start Visual Studio. Error: Invalid Class String"
[UPDATE] Advanced Installer cannot import VS Express solutions because the API from VS that provides assistance on import is not available for VS Express edition. Only solutions created with paid editions of VS can be imported in Advanced Installer.
So how can I log or see what is happening to debug this?
Users are getting a VSTO Exception while installing my addin on computers without my certificate installed (unknown certificate). The certificate is a purchased code signing certificate class 2, which is working on another application.
I create my installation files via ClickOnce. The ClickOnce setup.exe gets signed and I am signing the dll in the Post-build with
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\signtool.exe" sign /f cert.pfx /p pw "$(ProjectDir)obj\Release\myAddin.dll"
I want to deploy the addin via C# code in another application. If I register my Addin in the registry i get the above error.
If I run the setup.exe it is installing properly, but this is not a option since no silent install is supported.
How do I get rid of the error? Or is there any other way to install the Addin silently? Thanks
you can make the MSI from vistual studio using "Visual studio installer as a new project" in this wizerd link your project output to the Setup Project and copy the manfiest file manually into the dependencies folder of the Setup(the project you are using to make MSI).
then you can run the MSI as silent via Group Policy.
dont know if thats help but thats how i am doing currentaly for my project.
Thanks