.net core console app not runing when called from .bat file - batch-file

I have created a .net core 2.0 app and can run it by using Powershell and navigating to the project folder and calling dotnet run.
If I add a .bat file containing the above command and call myFile.bat I get the error
'´╗┐dotnet' is not recognized as an internal or external command,
So I tried adding dotnet myProject.dll in the batch file and get the same error.
I have read the the two ╗┐ characters are an encoding issue, so I changed my .bat file to UTF8, but that had not effect.
What have I done wrong?

Those strange characters are indeed an encoding issue, they are called Byte order marks. These are useful to programs which consume text streams, informs them of some meta information about the text that follows.
Not particularly useful for you however because the windows command prompt does not understand them. To fix this open the file up in notepad and save the file with an ANSI encoding, cmd should understand how to handle it.

Related

How to start c app from desktop with double-click?

I have written one very simple app in C. I know how to run it through Visual studio, but i want to start it from desktop with a double-click. If I double-click on a .exe file made in folder, it does not start. How can I do this?
If you do not wish to modify your code so that it will wait for user input before closing (and there are many reasons that might be inappropriate), you could create a batch file wrapper:
myprog.bat
myprog.exe
pause
Then either you can double click the batch file or create a shortcut to the batch file then edit the shortcut to set the path to the batch file and the path from which to run (so it can find the exe).
That pretty much emulates how Visual Studio runs your code without terminating the window.
Another method you might consider is a batch file such as:
runner.bat
%1
pause
Then you can drag-and-drop your executable onto the runner.bat icon to run it. The advantage being that you don't have to create a new batch file and/or shortcut for every new executable.
Really though this is not a C question, or even a programming question - it is most likely off topic. If your code is ever required to run to completion unattended in a batch file for example, you would not necessarily want to add any interactivity to the program itself.
Your problem is that double clicking on a console app will open a new console window, run the program and then close the window.
VS studio does a trick where it runs the app in a new console window but keeps it open till you press a key.
You can add that same thing yourself - put a getchar() call at the end
Or you can make a bat file to run the app as per Cliffords answer
1st open the code with visual studio code
Run or Build the program
then u will find an executable file where u have saved your code
Open that executable file
but you must have installed mingw installed in your environment
you must compile it first with mingw or like compiler. and start it with by code:
cmd> yourdirectory(e.g Desktop)/ gcc yourcodefile.c your question is available also internet => how-to-compile-c-program

Quickest way to create a .bat file (as .txt)

I have a couple lines of code in a batch file in Windows 10 that open a session of Octave, and load a script that uses design parameters contained in a .txt file. The batch file is named (for example) "Design123.bat", and when Octave runs, it automatically finds the design parameters in the file "Design123.txt" by simple string manipulation of the file name, i.e. strrep(filename,".bat",".txt"), where filename = '%~dpn0' is passed to Octave from the batch file. This allows for the contents of the batch file to stay simple and constant, and the file name of the batch file is the only thing tying it to the .txt file.
I do all of this to allow running the Octave script by double-clicking the batch file for convenience, instead of being forced to use the more tedious process of uigetfile in Octave. This works very well, but the catch is that I have to place a copy of the batch file in the same directory with the design (.txt) files (of which there are thousands, but each within their own directory) and give it the same file name to get it to work. Is there a way to quickly create the batch files somehow? The most ideal situation I can think of is to be able to right-click (or somehow select) a .txt design file, and create a batch file (replacing .txt with .bat) and place my lines of code into it.
Any ideas? I have coding experience, but only in software packages like VBA and Octave, not within operating systems themselves, though certainly willing to learn if I could get pointed in the right direction. The design file names follow a distinctive pattern, so they could be filtered easily within an operation on the active "File Explorer" window in Windows 10, if something like that is possible. Thanks in advance.
You might want to compose the answer to your question from calling the script on the right click and running the .m script with command line arguments.
If that fails, uigetfile is certainly not the only method to get file. At the very least you could always copypaste a path string to a folder from explorer to octave function call.
Finally, I guess I'll mention the existence of octave-cli which runs in terminal instead of gui. It might be better suited for running non interactive scripts.

Why isn't my Batch file opening when windows start?

The batch I created is intended to start a Python file, and for reasons of dependency with Python and Geckodriver, I have no way to work with the Batch file directly in the Startup folder, for this reason I need to work with registries.
I entered the following key in the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run path:
But for some reason the Batch file associated with the key does not open when Windows starts. I already checked everything, the Batch file works perfectly when executed manually and path in the key value is totally correct. It is not working on RunOnce either. I also checked the Startup tab in the Task Manager and it is enabled. Does anyone know what could be happening? why is the file not working?

A gpload control file processing error occurred. Entry must be a YAML sequence

I want to load data into a greenplum database with gpload.py (Windows Server). But I only get a weird output:
|ERROR|A gload control file processing error occured. The gpload:input:source(1):file entry must be a YAML sequence
I tried to use gpload with linux and it worked fine. So my yaml file and my input data should be correct.
Does anyone know how to fix that problem?
You should post the yaml config file you are using to make sure there are no other problems. But I would guess since you said that it works on linux but not on windows that you have a line ending problem.
YAML files are line and whitespace sensitive. Try editing the file with a local editor on the Windows machine.

making .exe from .bat file tools and solution with dependencies

I have got a solution that uses a .bat file to start. I need to make it a .exe. I have used different tools like [BATch to EXE], [Bat_to_exe_converter], Bat to Exe Converter from [f2ko] which was the most modern one. I need help on the last one which is more sensible to work. or any other solution that makes a working .exe file. Right now, after converting the file to exe according to dependencies the start-up process will not complete. I should mention that the bat file is the Pentaho start-up file.
I have also used IEXPRESS from windows but the error after running the result exe is:
"Error creating process . Reason: The system cannot find the file specified."
Thanks,
Sounds like you need Carte. Carte is a web service that allows remote execution of jobs and transforms.
Carte User Doumentation
You'll probably also need to see this:
Carte as a Windows Service

Resources