Lazarus on Windows: Why the extra terminal window? - windows

I built a Lazarus GUI application using Ubuntu and then took it onto Windows to compile. On Ubuntu I run it from the terminal like this:
./prg arg
It runs fine using the argument arg passed to it. On Windows this is what I did:
Create shortcut to exe
Edit shortcut and include the argument.
To run on Windows, I run the shortcut.
It works fine but there's an additional terminal window opening behind the application, when I run the shortcut. When the application exits, the window closes with it. The terminal window is empty.
On Windows, before compiling I had to uncheck the -WG switch in compiler options. This was because althought the app is GUI-based, there is a simple routine that checks for the argument passed at command line and uses Writeln to output a message if there were errors.
My key question is why is this terminal window coming up on Windows and how do I get rid of it or suppress it?
Thanks!

(1) Make sure you have set {$APPTYPE GUI} in your code. Otherwise there will be always a "terminal" opened on windows.
(2) Maybe you are confusing a "real" shortcut (*.lnk) with cmd/batch file? The latter also opens a terminal that dies when the lauched app closes.

Related

Virtual Studio Code - Getting the Terminal to pause after execute the program

I'm running my code in the external Terminal. When I get to the end of my program, the Terminal automatically closes.
Is there a way to keep it open, like the "pause" command on Windows?
Working on Windows as well
Thanks for the help

How do you run programs in Windows terminal?

What is the windows equivalent to "./filename"
So for example I would usually compile by doing something like:
gcc -c homework1.c
gcc -o homework1 homework1.o
This would give me the executable names homework1
And for me to run the program, I would type: ( ./homework1 ) <-- ignore the parenthesis.
Usually I was write all my code in my schools Unix Shell thingy and I also compile it and run it there, but recently I think I took up all the disc space (because it says "disc quota exceeded").
Run cmd.exe
Go to where the program is example : cd C:\foder1\
Then type the program name with extension, for example : test1.exe or "test1.exe"
In windows (as in Linux) you can either run a program though a GUI interface or from a shell environment.
The GUI option is a program called Explorer, you navigate through the file system and double click executable files to run then. Executable typically have the extension '.exe' or '.bat', but there are others.
The shell environment in windows is called the 'command prompt', you can run it by going to the start menu and selecting 'run' or simply press the windows key and 'r' simultaneously. A box will popup, type 'cmd' (without the quotes) and hit enter - the command prompt should open. From there you can navigate the file system using commands like 'cd'. To run your executable type the name of the file (it should work with or without the '.exe').
A nice shortcut to open the command prompt already at a particular path, is to browse to the folder in Explorer, hold shift and then right-click the folder - the resulting context menu that pops up should have an option like 'open in command prompt'.

Keep Windows command window open

I'm running a command through the Windows shell- an existing command window (cmd.exe). When I execute the command, the window closes, even though it's a freestanding window not tied to the command.
How can I keep the window open to see the output?
You can't simply start a child cmd session because it'll share same window and if your custom tool actively closes its window (I wonder why) then it'll close your console and output will disappear.
There isn't much you can do if a program want to close console window but you can at least save its output to a file (to be inspected later with type). If you're working with that console and you don't want to close it then you can use start cmd to execute it in a new console window. Like this:
start cmd /c tool -args ^> output.txt
tool output will be available in output.txt after it finished.
It appears that the executable is closing the command window. Here is what you could try, may work. open a command shell. In the shell issue "cmd" and open another command shell. Run your executable in the newly opened command shell. You nested cmd will be exited, but you may still be able to see some of the output of your executable.

how to make my console in python not to close?

I'm making a application in python from Windows. When I run it in the console, it stops, shows an error, and closes. I can't see the error becase its too fast, and I can't read it. I'm editing the code with IDLE (the program that came with python when I instaled it), and when I run it with the python shell, there are no errors. I would run it from IDLE, but when I use the console, it has more features.
I don't know why this is happening. I need your help.
Run the program from an already-open terminal. Open a command prompt and type:
python myscript.py
For that to work you need the python executable in your path. Just check on how to edit environment variables on windows, and add C:\PYTHON26 (or whatever directory you installed python to).When the program ends, it'll drop you back to the CMD windows prompt instead of closing the window.Add code to wait at the end of your script. Adding ...
raw_input()
... at the end of the script makes it wait for the ENTER key. That method is annoying because you have to modify the script, and have to remember removing it when you're done.
Run your program from a Windows command prompt. That will not automatically close when the program finishes.
If you run your program by double-clicking on the .py file icon, then Windows will close the window when your program finishes (whether it was successful or not).
Create a text file in the program directory i.e. wherever your script is located. Change the extension to .bat for example text.bat. Then edit the text file and write:
python main.exe
pause
Now you can run the program without typing into the command console by double clicking the bat file, and the console window will not close.

Stop vim from flashing command prompt in Windows?

Vim under win32 opens a command prompt (vimrun.exe actually, which opens in a terminal window) on every external command, silent or not. Yes, the terminal closes automatically, but it is still quite annoying.
This makes plugins that make extensive use of external commands, such as syntastic (it runs a command on buffer open/save), a real pain.
Is there some way to fix this behavior? What I want is for the terminal to open only for non-silent commands.
Rather than just ![windows command] you might try:
!start /min [windows command]
Alternatively, if you define a shortcut to a windows app you can click on the shortcut's properties and set it up to run as 'Minimized' rather than as 'Normal'
In both cases above an app button will show up on taskbar as the app is opened, as there would be for any minimized application. But it's less intrusive than having an actual window open.
NOTE The !start command solution runs the command asynchronously, resumes Vim immediately without waiting for the command to complete, which may often not be what you want. In that case the use of shortcut set up to run as minimized is better solution.
Just to bring closure: I wrote a replacement runner utility for Vim on Windows that doesn't open a visible command prompt. Here it is: vimrun-silent.

Resources