bla.exe (application alias) points to a .net application called wpfapp1.exe.
When i add a key&value to eg. this key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\bla.exe
and then start application using Run -> bla.exe it starts
however when i start application using windows search i get an "windows cannot find wpfapp1.exe. make sure you typed the name correctly, and then try again."
I have successfully identified problem: this error only occurs to .net applications while native one start normally (eg. firefox.exe).
So is there any .net config that i've missed during development?
From MSDN:
The App Paths key is not used when
computing the DLL search path.
Maybe you're missing some dependent DLL...
I don't really understand your "points to" or if Windows search is specific to using the explorer search or using the start menu search.
I've had a similar problem with another application that the search could not find at all, neither in Explorer or Start menu (since it did not have an indexed folder to locate it) and solved it with a simple shortcut.
If you can create a shortcut of your application in your start menu or some other indexed folder, like a %PATH% folder, Windows search should be able to pick it up and then you can name your shortcut to whatever you want, for instance bla.exe.
Related
I would like to build a simple .NET application that installs on a windows machine which will allow the end user to open a command prompt and type "google test" which will open google and search for test. But I'm not sure how to install a global "keyword" such as "google". Is this down via Environment variables? How does this link up to my .NET application?
Any advice or pointers is appreciated.
Thanks
This is beyond a .NET application and belongs into the Area of Setup programms. Visual Studio used to have a Installer Project, but as there are so many 3rd party ways this was removed.
Having "google test" parsed as a google search for "test" is tricky, but possible. However it depends entirely on how the commandline is parsed in a Windows. Wich is pretty much the way it was parsed since DOS 1.0.
If you just enter a word like "google", the commandline will look if there is a Excetuable file (.exe, .com, .bat) of that name in the current folder (working directory). It will then look into all the folders defined in the path variables. However using path variables is so dated, I could find only a single entry in my Windows Path variable now. And it is for MS backward compatibility: "%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;"
Most starting of programms is done via file associations with a specific type. And protocoll associations with a protocoll (like http, https, steam). Indeed my advise would be to make a .NET Programm named "google" whose sole purpose is to to format the proper URL, then send it to console parsing via ProcessStart. And let Windows solve wich programm to use from there.
Edit: And as I only realized after wirting this, apparently Windwos finally supports commandline aliases. https://learn.microsoft.com/en-us/windows/console/console-aliases
Apparently they even added a way to make them via the WinAPI in Windows 2000. However that requires moving to unmanaged code. And I have no experience, but it appears those aliases might only be valid for one console instance. So you might have to put it into a place like hte autoexec.bat to be called everytime a console is created.
I would like to set up min winforms app to use the IntelliTrace stand-alone collector.
Iv downloaded the application but I cant seem to find how I set it up to winforms.
It should be in this link I guess, but I dont quite understand: https://msdn.microsoft.com/en-us/library/hh398365(v=vs.110).aspx
Does anyone have any advice? Im trying to google to find examples without luck.
Best regards
Rob
I have a powershell script that I use to collect traces from console applications. This should be the same for winforms (I've tested it against WPF application and it works). The only step I'm not sure on is what "Collection Plan" you need - this might take a lot of experimentation.
Good Luck!
#1) Create a C:\IntelliTrace and place this script in there
$ROOT_DIR = $PSScriptRoot
#2) Extract the intellitrace cab file to C:\IntelliTrace\IntelliTraceCollection folder
#3) Where is the path to the winforms executable?
$Prog = "C:\path\to\my\winformsApplication.exe"
#4) Where do you want to save the trace?
$OutputLog = "$ROOT_DIR\MyTrace.iTrace"
#Note use of relative paths
$IntelliTraceStandAlone = "$ROOT_DIR\IntelliTraceCollection\IntelliTraceSC.exe"
#YOU WILL MOST LIKELY NEED A DIFFERENT COLLECTION PLAN
$collectionPlan = "$ROOT_DIR\IntelliTraceCollection\collection_plan.ASP.NET.default.xml"
#5) Run it..
#Note "dot space $IntelliTrace..."
. $IntelliTraceStandAlone launch /logfile:$OutputLog /collectionplan:$collectionPlan $Prog
Download Intellitrace standalone collector
Double click on the .exe file
Put the IntelliTraceCollectio.cab file in a folder.
For example D:\Intellitrace
Open command prompt as an administrator
Go to specified path of IntelliTraceCollectio.cab
and enter the command
expand /f:* IntelliTraceCollection.cab .
(Don't forget to put . at end)
Using command prompt,
enter
icacls "D:\IntelliTrace" /grant
(D:\Intellitrace is the path of your folder as specified above)
Create one more folder as D:\IntelliTraceLog (To store the collected intellitrace log file)
To collect data from an application, enter command
D:\Intellitrace\IntelliTraceSC.exe launch /cp:"D:\Intellitrace\collection_plan.ASP.NET.default.xml" /f: "C:IntelliTraceLog\MyApp.itrace" "D:\xyz\abc.exe"
(D:\xyz\abc.exe is the actual path of your file you want to run)
Now you will get an itrace file in D:\IntelliTraceLog. Open it in visual studio enterprise. Select any exception and click on Run Debugging.
You need to use IntelliTrace stand-alone collector to launch your WinForm application. You can find the reference from the link you posted https://msdn.microsoft.com/en-us/library/hh398365.aspx#BKMK_Collect_Data_from_Executables
PowerShell cmdlet is for web application or sharepoint application. For other managed application, the command you should use is
<FullPathToIntelliTraceCollectorExecutable> \IntelliTraceSC.exe launch /cp: <PathToCollectionPlan> /f: <FullPathToITraceFileDirectoryAndFileName> <PathToAppExecutableFileAndFileName>
I would like to get list of installed programs as shown in Add/Remove Programs of the control panel using C sharp
I know using SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall (32bit) or SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall (64bit) can get program names but how to get its exe file name?
Example MS Word is the program name which the above mentioned registers help me to get but its application file is winword.exe. I need to get this information so that I can start those applications through the code
Edited:
I need to to get the list of installed programs along with their exe information so that when user selects that program name from my application I should be able to trigger that application
Windows Add/Remove does not contain that kind of information.
Let's take Office as an example, you install a whole package, having excel.exe, winword.exe among others.
What you could do, is cross that information with the one available from the Start Menu, where most of the shortcuts are.
Most people don't delete the Start Menu shortcuts, so maybe it is an option.
Another one, would be to read the installation folder and filter out every .exe
Check this for executing lnk: c# memory usage for starting lnk shortcuts
I have an application that works weirdly: the setup process copies the files to a temp folder, then checks a few things, and if everything is ok, moves the files to the final folder.
The problem is that the installer creates the shortcuts before the files are moved.
The result is that on the start menu (the one with the tiles), the icon is the "default sortcut" one.
I have tried to force the refresh of the system using this link (broadcast a WM_SETTINGCHANGE message) but it doesn't seem to work for the Windows 8 start menu.
Even rebooting the OS doesn't seem to refresh the icon, the only thing that works is to reinstall the soft on top of itself.
How can I force the icons refresh for the Win8 start menu ?
Thanks
First off, you don't tell us why your install process needs to work the way that it does. I agree that's weird, but I assume you have a good reason for doing it that way. If not, I suggest starting there and fixing the installer rather than putting band-aids on individual problems. You're bound to run into other problems later, and the root fix is bound to be much simpler and easier to maintain than a bunch of band-aids.
Anyway, if you must go down this path… The reason that broadcasting a WM_SETTINGCHANGE message doesn't work is because this doesn't have anything to do with icons. Those are managed separately by Explorer and don't get rebuilt unless you delete its icon cache. That, naturally, prompts it to rebuild it. It's a common troubleshooting technique for end users, but it's not something you want to do programmatically. Talk about an ugly hack. And altering the global state to solve a local problem.
Besides, if rebooting the OS doesn't work, you know it's not as simple as you make it sound in your question: a property in need of a refresh. The reason that reinstalling on top of the existing installation works is because when the shortcut gets created in the beginning, its target executable already exists in the expected place (put there by the previous installation) with a valid icon.
What I recommend doing is writing some code to change the icon of the existing shortcut. Make sure that you execute it after you've copied the executable file to its final destination. The method that allows you to do that is IShellLink::SetIconLocation, which takes two parameters: a path to the icon (this would be the path to your executable file), and the index of the icon (this would probably be 0 assuming that the icon you want is the first and only one contained in the executable).
Of course, in order to call SetIconLocation, you're going to have to obtain an object representing your shortcut that implements IShellLink. This is a COM interface, which I don't believe is wrapped anywhere by the .NET Framework. General information on creating shortcuts from C# is available in the answers to this question. More specifically, there's a link to this wrapper class that you can use to do most of the dirty work. I don't think it contains a method for setting/changing the icon, but that can be trivially added.
Alternatively, you can get at these same properties using the Windows Scripting Host (WSH) wrapper, WshShortcut. It has an IconLocation property that works much the same way except that it takes only a single string argument, with the index delimited from the path by a comma: myApp.exe, 0. It's not particularly well documented (best I can find), but to get an existing shortcut, you just use the CreateShortcut method and specify the path to the existing shortcut. For example:
public void SetShortcutIcon(string shortcutPath, string iconPath, int iconIndex)
{
// Note: no error checking is performed for the parameters!
// This is not production-ready code!
// If a shortcut does not exist at the specified path, you should
// create a new one instead.
// If iconPath does not specify a valid executable file, you should
// set a default icon or perhaps abort.
IWshRuntimeLibrary.WshShell wsh = new IWshRuntimeLibrary.WshShell();
IWshRuntimeLibrary.IWshShortcut shortcut = wsh.CreateShortcut(shortcutPath);
shortcut.IconLocation = String.Format("{0}, {1}", iconPath, iconIndex);
shortcut.Save();
}
Note that in order for the above code to compile, you will also need to add a reference to the Windows Script Host Object Model to your application. To do this, right-click on the "References" folder in the Solution Explorer, click the "COM" tab, and find "Windows Script Host Object Model" in the list.
I just tested this and it works; the effect is instant.
i made a windows service & add project installer.in which only contain this code.
System.Diagnostics.Process.Start(#"C:\Windows\system32\notepad.exe"); inside the timer tick event & interval is 60 sec.i just wanted to try to run Windows service.
1st-serviceProcessInstaller1 i have been changed its account setting as local system.
2nd-serviceInstaller1 in this case i have been changed its start up type as Automatic.
then i create a setup add another project then right click add project output then add primary output then press ok.
then go to Right click on project->view->custom Action->right click on Install->Add custom Action->select Application folder & add primary output.the same thing done for all the remaining options like commit,rollback,uninstall.
after that i build the setup it build succesfully then i install the setup it installed properly into program file n create one .exe file n one Instalfile.
but problem is that when i search the service into "services.msc" the service is not there.
means service is not showing there.i tried but not getting the ans.plz help me to solve this problem.
Not the answer to your original question, but
Starting an application with a GUI from a service is a bad idea (tm) and won't work in the majority of cases
Check what kind of Timer you use. .Net provides 3 Timer classes, not all of them work in a service (because they depend on a window's message loop, iirc)
To test any service: Why don't you go for the installutil binary first (bypassing the setup project)? You find it in your framework directory, for example in "C:\Windows\Microsoft.NET\Framework\v2.0.50727".
I'd suggest trying to install the assembly manually to see if you get any kind of error message.
Just open a Visual Studio command prompt and run InstallUtil.exe [YourService].exe. At least you'll know if it installed properly.
Even better option is to use the command line tool sc.exe
Try "sc create /?" on command line and see its options.
You can then use "sc start " , "sc stop " & "sc query " to control service. You can use sc.exe to send custom command to the service. Check windows event log for errors related to service installation. It may be .Net version used to create it is not on target machine.