Programmatically changing assembly (application) name? - c#

I have a WPF project running on Windows 7 Embedded & Windows 8 Pro. In the taskbar when the application is pinned and I right-click the application icon, the C# project name pops up. Is there a way to change this name programmatically?
I want to load the application name from an .ini file at run-time.
UPDATE:
I have prior to asking this question searched and reviewed the other question that asks a similar, but different question on how to change the file name after compilation. I do not want to change the file name, just the name on the taskbar after right-clicking the application icon that is pinned.

I would say there is no "easy" way to do it, necessarily.
I would assume you have to run some sort of script or use Powershell.
Using method ?, create or rename a shortcut to your .exe with the name you want to show up in the pinned application.
Start the application using the shortcut. (At this point the "application name" in the task bar is the name of the shortcut used to launch your .exe)
Pin the application.
Shortcut is added to AppData, and the application will remain the same name of the shortcut.
Here was my pinned task bar info: C:\Users\me\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar
You could also probably modify the registry and add the shortcut straight to the folder listed above, then reload explorer.exe, but you have to worry about user permissions and what not. Either way, this should give you something to roll with.

Related

Run Wpf application from CMD/Run like calc?

I want to provide my WPF application a custom command so I can start up it from command prompt by not writing it's name but by writing specific command like calc or appwiz.cpl. I have searched google for the same but it is taking me wrong like almost concepts are of command line argument but I am not looking for the same. Is there any possibility to start a custom application from command line or run utility.
Thanks in advance.
Yes. That can be done easily using Windows Registry. You can open any desired 3rd party program by just typing its name in RUN or Start menu Search box and press Enter.
You'll need to set the application path in Windows Registry so that Windows can know about the application at the time of execution.
Type regedit in RUN or Start Menu search box and press Enter. It'll
open Registry Editor.
Now go to:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
Now we'll need to create a new key under "App Paths" key. Right-click on "App Paths" key and select "New -> Key". Set its name to your desired application name along with its extension e.g. My_Application.exe
Select the key created in Step 3 and in right-side pane, set value of "Default" to the full path of application's EXE file e.g. C:\Program Files\My Application\My Application.exe
Again in right-side pane, create a new String value "Path" and set its value to the folder containing your application EXE file e.g. C:\Program Files\My Application\
That's it. Now you can launch your desired application by just typing its name in RUN or Start menu Search box.
NOTE: If you want a ready-made registry script to do the task automatically, then copy paste following code in Notepad and save the file with name "AskVG.REG" (including quotes).
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\My Application]
#="C:\\Program Files\\My Application\\My Application.exe"
"Path"="C:\\Program Files\\My Application\\"
You just need to replace BOLD part of the above script with the correct application name and path. After saving the file, run it and it'll add the program path to Registry so that you can launch it directly from RUN and Start menu Search box.
Edit:
Based on your comment you can write the following action with C# code

Visual C# icon issue

I have recently finished a Visual c# project. During the process I tried multiple icons for the form and for the icon you see on your desktop. I found one that I was gonna use for both, but for some reason the icon that you see on your desktop is the old one that I used previously even though I changed it in Properties -> Application -> Icon and Manifest
Windows File Explorer uses an icon cache. You may need to clear this cache to get it to refresh.

How does the InstallAllUsers option work?

I have a C# application, and a Visual Studio (2010) Setup Project with it. In my Setup Project, I am using InstallAllUsers = True. Additionally, my application needs to launch at Startup, so a shortcut is being added to the User's Startup Folder.
So I install my application as user Bob (from a share), and then I log off and log on as user Alice. Alice gets a dialogue that says:
The feature you are trying to use is on a network resource that is unavailable.
It provides the network path from which the MSI was installed. So, basically, it's looking for the MSI on a share that Alice doesn't have access to. This is repeatedly reproducible if Alice tries to manually launch the Startup link. However, Alice can directly launch the exe from the installation location, which works fine.
I don't fully understand why it is looking for an MSI, but I guess it makes sense that an application can not be completely installed by one user for another user, so the MSI is needed to complete the installation.
But if that is the case, then I don't understand why the MSI only seems to be required when launching from the Startup link, and not from the exe directly.
My question has several parts:
Is what I am experiencing expected behaviour for the InstallAllUsers option?
If so, how can I ensure that my application is fully installed for all users?
Is it necessary to copy the msi locally, and ensure that it does not get deleted before each user has had a chance to log on?
This is happening because the shortcuts are "advertised shortcuts" hence the greyed out target box.
More info here...
http://www.advancedinstaller.com/user-guide/advertised-shortcuts.html
When an advertised shortcut is launched it validates the checks
associated with the key resources. If any is missing it will fix it by
running the installation package and installing again all information
from the .msi file.
This is why its trying to run the msi.
You can turn off advertised shortcuts by reading this article...
DISABLEADVTSHORTCUTS=1 disables all shortcuts
If its an all users install, then the shortcut will probably want to reside in the all users start menu. Win 7: C:\ProgramData\Microsoft\Windows\Start Menu.
Eric, I would recommend taking a look at the shortcut file contents. You can do this by using Powershell, and there is a SO link to help you on your way:
Editing shortcut (.lnk) properties with Powershell

Optional User's Desktop shortcut issue

(Using VS 2010 with a Visual Studio Installer project.)
I have added a 'Checkboxes(A)' dialog to the 'User Interface' under the 'Start | Welcome' dialog and set a checkbox with the property set to "DESKTOPICON". The option is being displayed.
In the 'File System' the 'User's Desktop' has the condition property set to DESKTOPICON=1.
When I run the install on my VM the option appears to be ignored and the desktop shortcut under the User's Desktop list is always installed.
I looked at these similar posts but it does not seem to work for the desktop icon?
How do I specify Visual Studion Installer Conditions?
Visual Studio Deployment Project Optional Desktop Shortcut
Is it normal for the User's Desktop to ignore it's condition property or am I doing something wrong?
Visual Studio setup projects create only shortcuts to installed files. This type of shortcuts are linked to their target and share the same component.
Since in Windows Installer you can condition only components and features, you cannot condition a shortcut directly.
A common approach is to write a custom action which removes the shortcut. You can then condition the action instead of the actual shortcut or its folder.
Well, I know it's been a long time but today I faced exactly the same issue as mentioned. I wanted to try creating a windows installer in VS 2013 using "Installer Projects" extension thing and wanted to make a checkbox with condition whether create a desktop shortcut or not.
Like above, shortcut under User's Desktop was always installed.
After wasting almost 3 hours I found a workaround on the old Microsoft Connect feedback post: (which apparently was already dead for some time)
Ok I got this to work by adding the main file twice to the folder (the
file you are creating your shortcut to). I tie the shortcut to one of
the files and on that file I set the condition to CHECKBOXA1=1 so it
will only create that file and the shortcut if they check the the
"Create Shortcut" box. For the other file I set the condition to
CHECKBOXA1<>1 so it will create it when the check box is anything but
1 (not checked).
originally posted by Chancea on 7/1/2010
I tried to do it that way - it works as intended. Not really convenient whatsoever (can mix up the same looking names etc). For a really, really simple installer thing (which I needed) with an only additional feature, adding shortcut to desktop, it might be fine however.
Nevertheless I still think it only proves that this is just a port of an Installer Project from earlier versions of Visual Studio, now added by an extension.
The idea may be good and useful I think, but I wish they fixed just some of the Windows Installer project in VS issues and lack of features.
Like I said, it would be great option for people (... like me) who want to publish some pretty small and lightweight apps, and needs only some basic features from the installer like (optional desktop shortcut, adding to startup, installing some additional files etc etc).
Well, I guess the conclusion is that I'd just have to start learning WiX or try out the InstallShield
After another 2 1/2 years in VS2019: The problem remains that the shortcut created in the "User's Desktop" folder can not handle the condition imposed by the checkbox. Thus a somewhat simpler (but also not "clean") solution would be not to duplicate the exe (e.g. myApp.exe) like in Skippers solution (it did not work for me), but to create an additional myApp.bat file doing nothing but starting the myApp.exe.
The simplification consists in the fact that only a condition on the myApp.bat file is necessary, and no one on the myApp.exe file.
The following steps worked here:
Create a myApp.bat file doing nothing but starting myApp.exe, i.e. containing the single line "myApp.exe" (without the quotes). Of course, commandline parameters would be possible if necessary.
Put myApp.bat into the "Application Folder" of your installer project.
Set the condition on myApp.bat to CHECKBOXA1=1, meaning it is created only in case of the CHECKBOXA1 having been set.
In the "User's Desktop" folder of the installer project, create a shortcut to myApp.bat (Context menu "Create new shortcut"), give it the icon of your app ("Icon" property). Do not specify a condition. Here in my case (VS2019 on Win10) this resulted in a NOP action when the myApp.bat was not created (checkbox unchecked), and properly created the link on the desktop when myApp.bat was present (checkbox checked).
For this shortcut, you might wish to set the "ShowCmd" property to vsdscMinimized, to avoid the large command line window of the bat file.

Icon in WPF Browser application

I have a WPF Browser Application consisting mostly of wpf pages which I'm developing in Visual Studio 2010.
I'm publishing the app to the intranet, with ClickOnce at full trust.
Is there any way to have an icon for the pages in this type of application? (which would show instead of the internet explorer icon in each of the tabs of Internet Explorer), I'm executing it through PresentationHost.exe.
What I'm trying to do, is to have a desktop shortcut with a custom icon for each part of the application (two different projects in the same solution).
If there isn't a way to do it with XAML, is there any way to run any commands or a batch file at the moment of accepting the ClickOnce prompt?, to place the shortcuts in the desktop with their respective icons at the moment of installing the application.
Thanks in advance, Jesús.
P.S: I know my redaction skills suck, so if any more details are needed, let me know.
If you open your project file and change the HostInBrowser setting to false, and this will enable the ability to provide an Icon and Manifest in the project's properties.
<HostInBrowser>False</HostInBrowser>
I am not sure how that will affect your app though. Maybe this setting is supposed to be "True" to work how you need it to work.
Did you set the icon for each project, in VS right click on the project - properties - Icon and manifest - click the icon button ...

Categories