How to make .exe file programmatically set to run as admin always in vista? - winforms

I have written a winform application in C#. When I run the program for some functionality it required admin permission. After Installation If I set the .exe file to run as admin manually (by clicking right mouse button on .exe file) then my program run perfectly.
Now I need user not to set the run as admin property after installation by clicking right mouse button. I need to set this programaticaly somewhere in the code that user no need to bother about this. This specific problem is only arise for Windows Vista. Can anyone help me out?

You need to add a manifest to the app that specifies it require admin privileges. Read more on MSDN.
Update: You can add a manifest to your project by right-clicking on the project and selecting Add / New Item / Application Manifest File. This will add a new file called app.manifest to your project and will reference it from the project properties, in the Manifest dropdown on the Application tab. The default manifest template even has a nice comments on how exactly to change the required UAC execution level.

You need to specify the requestedExecutionLevel in the manifest.
See here for a detailed explanation:
http://petesbloggerama.blogspot.com/2007/04/making-your-assembly-run-as.html

Related

Running .bat file before .exe automatically in Advanced Installer

I'm new to Advanced Installer. After Installing the file setup, I need to run a ".bat" file before running my ".exe" file every time. I found to add it, setting it's attributes as (Hidden, Vital and System), but I need to run it every time before lunching the application.
Please help me, Thanks
If you're launching the application as a Finish Action from the Dialogs page, here are the steps:
go to Custom Actions page and add a Launch File custom action without sequence to launch the BAT file
enable the custom action's "When the system is being modified (deferred)" and "Run under the System account with full privileges (no impersonation)" options
go to Dialogs page, select the ExitDialog from First Time Install in the Install Sequence
select the Finish button then go to its Published Events tab and enable "Show all events" option
add an "Execute custom action" event passing in the "Launch file" created above as an argument
set the event's condition to the checkbox's name so the BAT doesn't execute unless the user selects the checkbox to launch your application
make sure the event is the first one in the Published Events list so it gets executed before the event that launches your application
There are a couple of articles to help you with other details:
How to launch a CMD or BAT file?
How to launch a file after an installation?
The main thing you need to consider is to run the event that executes the BAT custom action before the event that launches your application.
Also, I'm not sure you can do this from a Professional project type. You may need Enterprise or Architect.

icon in task bar will not change when winform is published

I have a winform app running on .net 4. When a certain condition happens, the icon running in the task bar changes from ping_logo to ping_logo_red. (the icon i'm talking about is the one that shows up when you run an application. You click on it and it will restore the windows to the screen or minimize it) The way that the icon is changing is as follows.
I added the ico files as Resources. In the code I change the resource being used
Me.Icon = My.Resources.ping_logo_red
Here is the thing. This works when I run the exe from my machine from the solution bin/release folder. When I publish this and install it from the published location, the icon does not change.
In the publish tab under the project both ping_logo.ico and ping_logo_red.ico are included in the publish status.
what have I not done that is keeping the icon from working in the published app. I've tried to uninstall the app and install it fresh but that doesn't seem to make a difference.
thanks
shannon
If you are using ClickOnce to publish your application then you need to set the icon property in the properties window of your project.
Right click your project -> Properties
Go to application tab
Select your icon file towards the bottom.
Another idea is changing the CopyToOutput property of your .ico file to "Copy Always" or "Copy If Newer".

Deploying Silverlight Application on IIS7

We have a silverlight application written in Visual Studio (VS) 2010 and we want to deploy it on a Windows Server 2008 R2 box (IIS7). To deploy it in VS I did a right click on the MyProject.Web project, selected "Publish...", from the "Publish method" I selected "File System". I copied the folder over to "C:\inetpub\wwwroot" on the server. In IIS Manager I did a right click on the folder, selected "Convert to Application", a window popped up, where you can select the application pool. I selected the default (.NET 4), I clicked on "Test Settings..." it failed (that was a bad sign), clicked ok.
When I try to access the website from a browser a message box pops up saying do you want to open or save "MySilverlightApp"?
Basically, it wants to download the xap file like it would download a text file or a doc file, it doesn't "run" it.
I have checked the forums and most cases the issue is that the MIME file types are not set up, but I have checked that it's all looks good, and it should as well because on IIS7 it's all set up by default so I am puzzled a bit here.
Thanks for your help.
I have just realized that you tried something about mime types so I need to edit my answer. I want to share a link to provide you a guide. It may be helpful to see if you miss a point.
http://www.iis.net/learn/web-hosting/web-server-for-shared-hosting/configuring-iis-for-silverlight-applications
The route cause of the issue was that the XAP file (inside the ClientBin folder) was the default document.
When I set the aspx file (in the application root folder) as the default document, it started to work fine.

System.Web.Mvc could not laod when publishing silverlight to discountasp.net

I made a simple silverlight web application that just has one button filling up the whole page. It publishes fine to discountasp.net, but when I try to access my website, it says it could not load the file or assembly System.Web.Mvc. I don't even see this in my silverlight project references.
In your MVC project, expand the references folder. Then click on System.Web.MVC and in the properties dialog, set "Copy Local" to true. You may need to do this for System.Web.Routing and System.Web.Abstractions as well. Then Publish your website, select FTP and enter your DiscountAP.net FTP address and username and password. Set passive mode to true.
Sounds like one of your assemblies is referencing the MVC dll. This will be in the GAC on discountasp.net. Download and install the MVC binaries on the webserver you are using and the problem will go away.
Although I am not sure why your site is looking for them. Check the web.config for assembly references.
Hope this helps.

No "Start" menu shortcut using ClickOnce

I am publishing a .NET 3.5 SP1 WPF application through ClickOnce. By default, when the user clicks on the published link the application gets installed and a menu and shortcut are added to the client's Start/All Programs menu.
How can I prevent the shortcut/menu from being created? (Users need to run the application solely by clicking on the hyperlink to the ".application" file on a web page.)
For this behaviour, set it as online only. Project properties -> Publish -> "The application is available online only" (radio button).
It will still do the same local caching of files etc; it is mainly the start-menu that changes (I don't have a full list of the differences).
This can also be changed in the .application file by setting <deployment install="false"

Resources