Run .net app in Vista/Windows 7 as admin - winforms

I have created .NET winforms application and setup project for it.
What I need is that after installation, my application always runs with administrator privileges.
Could someone tell me how I can configure my application to do that? Can I do it just by modifying source code?

Add a manifest file to your project and set the "requireAdministrator" settings. e.g.
Right click your project, add file
Select app manifest
Open the file and make your requestedExecutionLevel match:
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
If it's already installed, you can locate the exe and select properties. In the Compatibility tab, check the box at the bottom "Run this program as an administrator".

Related

UWP App WPF .Net Core has no access right to dependencies

We're making a new application using WPF .Net Core. To use the auto update function we decided to pack it with the MSIX Packaging Tool as a UWP App in VS2019. I was able to host the appinstaller File on an IIS and to Install the App over a link to that file over the web. Auto updating is also working fine.
Now to the problem:
When I run the installed App it's icon is not showing in the task bar but it is shown in the Task-Manager using a lot of cpu. In the Process Monitor it shows that the App tries to access its dependencies (like PresentationFramework.dll) but is not successful as the result is always "File locked with only readers". The DLL itself is present in the WindowsApps/xxx/ Path. Also I can not start the EXE manually as my user do not have the rights. What am I missing here?
Edit: Also I realized now that my app is only starting as a background process in the task manager and not as an app. When I go to the app directory under WindowsApps/xxx/MyApp I can not start the EXE directly because of no rights as mentioned before. But when I copy the whole folder I can start the EXE, the GUI appears and the app is an app again in the task manager.
We found an answer. As the GUI is a WPF .Net Core Project and we make the setup with a Windows Application Packaging Project to generate a UWP App from it the technology used seems to be the so called Desktop Bridge.
In the process monitor it seems that it tries to access the files under the correct path but somehow it does it not in the right way as long as the application path is not set correctly in the WPF Projects App.xaml.cs.
To fix this use the solution from Andrew Leader

How to deploy a WPF application?

I have developed a WPF application and deployed it using Click Once Deployment. I installed it on another pc it works fine but the problem is that the application's root folder is being created in a temporary folder in app data/local. I want to give user the flexibility of installing the software wherever he/she wants. How do I do this?
You simply can't change the installation folder using ClickOnce. If you want to do this you need to choose a different installer technology.
ClickOnce application require no administrative privileges and are always installed per user in the user application cache.

ClickOnce and app.config not deploying

I have a new WinForms application that I'm trying to deploy with the ClickOnce method. However, the app.config file that is needed for the application is not included with the installation.
The application is installed properly from the server, and launches the exe, but as soon as I try to login by hitting my WCF Server, I get.
"Could not find the file 'C:\Documents and Settings\Adminstrator\Local Settings\Apps\2.0\7KAA3h20\app.config"
I can manually copy the file from my development machine to this folder and the application works fine.
Any ideas?
The application settings are included in the ClickOnce application as yourappname.exe.config. Are you accessing the app.config through a different mechanism that the global app settings?
Config file is included by default. Are you removing it for some reason?
You can choose files to be deployed on properties page (application files) if you are using Visual Studio.
If file is not in the list, you can add it to project and set build action to "Content" and it will show up in this list.

Clickonce deployment with wpf

I've created a wpf application and its installer with Clickonce. But running installer on another computer causes exe file creation in Start-Programs-Microsoft. What should I do to make installer create a folder in Program files?
By the way, I also want a program to create a desktop shortcut, I put make the "Make desktop shortcut" checkbox enabled when customizing publishing options, but nothing happens.
Clickonce doesn't allow to specify a folder in Program Files, the solution was to create a Setup Project within the solution.
The Publisher name settings under Publish Options -> Description of the project properties in Visual Studio determines the folder under Program Files.
I usually follow below steps. Hope it may helps
Steps
1. Right click on the client project -> properties -> Publish tab
Publish folder location, installation URL(eg: http://LocalHost/Application/client/)
Click updates give same installation URL
Click options > give name and description for the application
Click Publish
Copy the files from Publish folder location and paste it in corresponding installation URL
Browse the install.htm
Click install
Some times before publishing you may need to create a new certificate (project properties -> signing tab > create test certificate (password not mandatory))

how to set silverlight out of browser application in windows startup

Hi
I have one silverlight application which I have set for Out of browser application so that user can installed on their machine.
Now my question is "Is there any way or configuration or programmatically possible that when my silverlight application get installed it will put it self in the windows startup so that when user logged in it will automatically starts like messenger applications (yahoo, msn etc)?"
Thanks
You could create a batch file that would do 2 things :
Install your app in OOB using SLLauncher.exe (silverlight executable fo OOB applications), It now have a /install option in its parameters you could use that method to install it.
Copy the shortcut to the"Startup" folder of the current user :
%UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

Resources