Run a published console app from win form app - c#

I have a win form application that accept exe file and folder path as argument.
Then a console app is launched. But in my case these console apps are
also published.
When I execute from Debug console app work but when I select
Setup.exe from published app the application installs and then
crash. With argument out of range error.
A related answer can be seen here. But it work with unpublished
exe which I am already doing.
Can I get name of the installed console app something like
"WINWORD.exe" or "Chrome.exe".

Related

How do you launch a C# Console App from a USB device?

I would like to run a console app from a USB drive. I have the project, the installation files, the deployable folder, and the starting .bat files all on the USB drive. The machine has the proper version of .NET to run the project but when the console app gets called the cmd window says "You must install .NET to run this application". Could I be getting this error because the working directory of the batch is on the USB Drive so the search for .NET fails?
Ideally when I click the start .bat (contained on the USB) it calls the executable in the deployable folder (USB) and passes it args which then installs the software (.exe or .msi contained on the USB but INSTALLING to the machine).
Gunr2171 suggested making the console app self contained. Using the docs found here https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/overview?tabs=vs we successfully published into a single file and it worked wonderfully!

Console Application, detect launched from an exe file or from terminal

I developed an console application, with the dotnet framework.
I want the application to run when called in a terminal session and when executing the .exe file.
Now I got a problem with the design of my application.
When launching the exe, I need to ask if the program should be terminated, so that the user can read the output of my application (otherwise the application and therefore the terminal would close before any human could read what hs been printed).
But exactly this process of asking before the application stops executing is annoying if the application has been launched from the terminal, let's say by running dotnet myapp.dll.
This is because when launching a terminal session the terminal doesn't close after an application has terminated.
So my question is if there exists any advice/ best practice/ or if there is a way of detecting if the application has been launched via an exe file or in the terminal.
Thanks for your advice.

How to build a WPF app so everyone can install and use it

I am entangled in how to work so that after I finish building the wpf app, I can give it to another computer by downloading the app (for example, downloading the .exe file). I also tried it, but when I ran the .exe file, it only showed a popup cmd and then disappeared. Then I have pulish with self-contanied deployment mode. Here is an image of the following files when I published at bin\release:
Path: C:\Users\ASUS\Source\Repos\UserService\WpfApp1\bin\Release\netcoreapp3.0\publish
If I run the .exe file in a folder then run normally. But when I copy it to a deskop and run it is still the same (can't run).
I want to ask how can I help my app to be used by other computers. Thank you mn! Forget more, my app is using .net core 3.0 already.

Launch .NET application from another folder

Here: Launch C# .Net Application from C++ they say it's possible to launch a .NET application using CreateProcess.
I can't.
Even from the command prompt (Windows 10) I can run my C# application only if I cd to the exe folder.
I've added that folder to the PATH env var, so my C++ application can run it without know where it actually is. But as said it doesn't run.
Trying with the command prompt it just says "This application cannot be started".
Is there something more I have to do?

Launch a WPF application from a batch file or console application

I've made a WPF application based on .NET framework 4.
This application will be copied to a pendrive, and the client will have to run it from there.
In order to check if the client has Framework 4 installed, I've made a batch file that read the output of "clrver.exe", and if the framework 4 is installed it runs the application using the command
START "application path"
The problem is that few seconds after the WPF application is running it crashes.
So I've tried to make a C# Console application, just to check, and using Process.Start() I've started the WPF application. The behaviour is exactly the same.
If I try to run the WPF application by clicking directly on the executable it runs perfectly.
If I try to run it from a console, it crashes after few seconds (5~6 seconds).
Does anyone know the reason or an idea on how to run it?
The problem was dued by the working directory that cause some problem when the application is launched by a console application or a batch file.
I've solved replacing all relative paths in my code with absolute paths retrieved at runtime with: System.AppDomain.CurrentDomain.BaseDirectory

Categories

Resources