Run as administrator not showing in start menu - c++

Background:
My C++ application developed by VS2008 and use the VS setup project to create installer for that. After installation it will create two shortcuts to application. one is in user desktop and second one is in start menu. Application(myApp.exe) installed to the Program files directory.
Question: If I right click on the icons in the start menu, there is a option Run as Administrator for most of them. But if I right click on the shortcut that related to my application. It doesn't show Run as Administrator. How to fix this?
Edit: But if i right click on the myApp.exe in the Program files, it shows "Run as Administrator".

Set your embedded manifest to require administrator. On the project property page:
...on the (highlighted) UAC Execution Level, change asInvoker to requireAdministrator. Build your project to embed the new manifest, and it should be ready to do its thing.
Oh -- I didn't think to do it here, but in the Configuration drop-down, you probably want to select All Configurations, instead of the (default) Active configuration that's selected in the screen shot. Gets seriously annoying -- you think you've got things fixed, then you change to "Release" and a bunch of stuff suddenly breaks, and you have to go through figuring out what you'd changed, and edit those changes into the Release configuration as well.

In manifest file there is option "requestedExecutionLevel" and "UIAccess" which will manage it.

I found the answer for this after so much testing and searching. So here I mention it for use of any one.
Windows only shows Run as Administrator in the context menu for that shortcuts those are directly targeting to some exe file.
If you use VS deployment (setup) project to create your installation with desktop and start menu shortcuts. Those shortcuts not targeting to exe (Application.exe) file.
Instead of that shortcuts targeting to application folder (MS office 2007 also same). This is called installation-on-demand and advertisement. Here is the more details.
This will help your application to repair from file missing (pray Google for more).
So we have to disable this feature if you want to target your shortcuts directly to exe file.
For this you can use command prompt or some tool. here is how to do it.
Nirmally windows installer having a exe and a msi.
These setting are stored at at msi generated with setup file.
So You have to alter the file and add the entry DISABLEADVTSHORTCUTS=1 to property table.
Using Command prompt:
msiexec /i <path to your msi> DISABLEADVTSHORTCUTS=1
Using Orca Tool:(Meny other tools also there)
Download Orca tool from here and install it.
Right click your *.msi file and click edit with orca.
Go to property table and add new entry DISABLEADVTSHORTCUTS and value is 1 , save and close.
Now you done.
Install using setup.exe file and check the target of the shortcuts. those are directly target to the exe file in application folder.
Now if you right click on the shortcuts those shows Run as Administrator option in context menu.
Note: Doing this you will gain Run as Administrator but scarify the windows auto repair capability.

Related

CLion forces files refresh after build, which takes too long

When I build a project in CLion, it also refreshes all of my project files (after the build, actually) - and if I have a lot of them, mounted from a remote server via a slow(ish) network, that can take some time. Can I avoid this refresh somehow?
In CLion 2020.2 and later, you can tell the app not to have to wait until the refresh is complete to consider the build concluded and to allow you to continue with other work.
To do this:
On the menus, choose "Find > Action", then type in "Registry".
Choose the Registry action; you've now opened the CLion registry (yes, it exists).
Type in: cidr.asynchronous.refresh.after.build
Check the box on the value column.
Reference: Here.

Run Custom Tool not available to generate resources.designer.cs

In my project on one computer with VS2017 Version 15.5.4 I have the ability to run a custom tool on Resources.resx
On another computer with VS2017 15.5.6 I have
The code is cloned from the same project
How can I get the custom tool working?
Right click Resources.resx and select properties
then right click the Resources.resx file with the propeties window open. Run Custom tool is now available.
Right click 'Resources.resx' and select properties then add in advanced->Custom Tool option this 'PublicResXFileCodeGenerator'. The Run Custom tool option is now available.

VS2017 Installer Project - Cannot Make Uninstaller

I have been able to successfully install a simple program using an Installer Project on Visual Studio Community 2017. However, I can't find out how to create a fully working deployable uninstaller for an end user.
The Installer Project was set up to only create an Application Folder (in C:\Program Files...) with the Program .exe, and nothing else. This it does successfully. I would like an installer because later I plan to make some registry keys upon installation.
To test uninstallation, I have run the original .exe file built by the Installer Project with the "Uninstall" option. This removes the Application Folder but does not remove the program from the Add/remove programs list in Windows - Leading me to believe there are other registry entries that have not been removed.
I have tried to uninstall purely from the Add/remove programs list, but then I get an error:
C:\WINDOWS\system32\msiexec.exe
"Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access the item."
In Visual Studio, I can click "Uninstall" from the Installer Project right-click menu which does successfully remove both the Application Folder and the Add/Remove Programs Item, but this is not a deployable solution.
Notes:
OS: Windows 10
Using Visual Studio 2017 Community
Looking at the application Folder, there is neither an install nor uninstall .exe file in it. The Installer Project .exe is only in the original build location, and I cannot find how to get a copy in the Application Folder (not sure if a copy there would work).
I have tried configuring the Installer Project as x86 and x64 with no change.
I have tried using both Debug and Release build configurations with no change.
From looking around, WiX seems to have more features and flexibility, but I haven't yet dug into that. Is there an easier solution?
Has this issue occurred to anyone else? My hopes were that Installer Projects were the simple way to learn and handle installation.
Looks like I jumped to conclusions in the comment above, however I think I found the issue: I cannot uninstall the program from the Windows Apps & Features window in System Settings, but uninstalling from Control Panel\Programs\Programs and Features works fine.
When typing in "Remove" using the windows start button, the default item that comes up is "Add or Remove Programs" in System settings (This looks like a Windows 10 thing). When you click that, it forwards you to the "Apps & features window. I am now learning that for some reason this has different functionality than the control panel window. Or maybe it has lower permissions, although I am the admin and only user of this computer...
Because it can be uninstalled from Control Panel, I think this would be the preferred solution. My assumptions about the other window in system settings was my real issue. I just wish the Apps & features window aligned its functionality/permissions with control panel.
I also learned that uninstall is successful when I run msiexec.ex /I{PACKAGEID} in cmd. Not sure how relevant this is, but documenting here.
Installs and uninstalls are transactional, they either work completely or roll back completely. If you do an uninstall but the entry remains in Add/Remove Programs then it's likely that the uninstall did not in fact work.
When you do the install, if it has a UAC elevation dialog then the install is running with elevation and installing files/registry entries to locations prohibited to limited users. Removing files from those locations also requires elevation. You haven't said exactly how your uninstall works, but most likely it requires elevation to succeed, and your program isn't running elevated. If your program uninstalls silently the uninstall will fail silently, so it's possible that your program isn't actually checking that the uninstall worked.
I'd also guess that your Visual Studio session may be running elevated so uninstall from there works fine.
Apart from privileges, an uninstall from a running installed program tends not to work very well because the uninstall process cannot remove your running program or its folder because it's in use. So while you could get it to work (with elevation) you might find that your program and its folder are left behind until the next reboot. If people really want to do this, one of the strategies is to copy an uninstall program to the temp folder and fire it off asynchronously, so everything can be removed.
Uninstalls from Add/Remove Programs&Features generally work fine. Without some context that error message doesn't mean much. It's not a message that comes out of Windows Installer, so it's perhaps coming out of a custom action. Otherwise it may be an issue specific to the test machine.
There is never an uninstall exe in a Windows Installer setup. When you remove a product the system just calls the Windows API to remove the product. Windows Installer is part of the Windows OS with API support for everything that needs doing. Only non-MSI setups require an install and uninstall exe to do anything.
None of these issues seem to be related to your choice of tool. They all create MSI files and if an MSI design is not optimal it doesn't matter what tool you use. There's nothing wrong with WiX, but to install literally a few files it's overkill compared to Visual Studio.

Eclipse Project Run problem

I tried to create a C++ project in Eclipse Helios, it works fine for some simple "Hello World" projects (a single file etc..). However, now I have a little bigger project with several files, the project can still be built without any problems. Actually, when I get into the release folder, the makefile, object files, the actual binary executable are all there. And I could run the binary through the termainl. If I click the "Run/Debug" in Eclipse for this project, it always says "Launch Failed. Binary not found".
How could run the program in Eclipse? I would like to explore its debug features. In addition, I'm running eclipse in CentOS linux and I believe the basic g++, gdb setting etc.. should be all right, otherwise the daemon hello world won't work.
Warning: I have a very old version of eclipse and the CDT so the current procedure could have changed considerably.
In the C/C++ Project view, expand your project then expand the Binaries node. In there you should have a list of the built executables. Right-click on it and select the item Run As.. > Local C/C++ Application. This should automatically create a new run configuration which you can access from the green arrow icon and the little bug icon in your tool bar. Click on these to run normally or to run in debug mode.
If you want to tweak how programs are launched, goto to the Run configuration menu item of the green arrow icon. Select the configuration that you previously created or make a new one. You can then tweak the various launch settings like the executable to run, the arguments you want to pass, the required environment variables, etc.
Note that there's also a separate Debug configuration that can be accessed from the little bug icon in your toolbar. Within that dialog there's a Debugger tab which contains all the controls necessary to set up your debugger. Just randomly screw around with the controls until you find something that works for you.
I just had the same error, and here is what I did - proper binary parser must be selected so Eclipse can recognize the executable:
Select the project, then right click.
Project->Properties->C/C++ Build->Settings->Binary Parsers, PE Windows Parser
(or you can select Cygwin parser if you use Cygwin compiler, on Linux I use Elf parser).
That worked for me at least for Cross compiler (both on Windows 7 and Ubuntu 12.04)

Set app to require elevation?

I'm working on the bootstrap application of a new installer for some of our products. So far, I've been relying on two things that I read about somewhere:
Applications whose name contains "setup" or "install" will run elevated by default.
Applications that run elevated will launch other applications in elevated mode.
Recent testing has found that one or both of these statements is false, because one of the applications that I'm launching is a third party installer that requires elevation, and it's failing because of the elevation requirement.
How do I set my application to require elevation? I know it has something to do with the manifest file. As I'm working in Visual Studio 2008, and the manifest file is generated, I'd like to know what to enter into the project's properties and where to make it require elevation.
When I couldn't find application manifest as a new item that could be added to my project, I went into the online help and found this:
configure the VS2008 in Configuration Properties - Linker - Manifest File - UAC Execution Level (requireAdministrator)
That did the trick.
In VS2008: Add new item; application manifest file (app.manifest; the comments in the template file tell you how to demand more access).
You can now specify the manifest in project properties on the Application tab (but you need to uncheck "Enable the Visual Studio hosting process" to debug it).