Launch4j Support of Console and GUI applications - maven

We have a java application that uses Launch4j to create a windows .exe. We achieve this using the org.bluestemsoftware.open.maven.plugin, which works great. I have one inquiry however. Recently I added cmd line functionality, and found that using the GUI header didn't pass arguments when run from the .exe. OK, that makes sense.
Using the Console Header works as intended (arguments are passed). However, now when we run it in GUI mode, I get the command window in the background, no pretty splash screen, and my window name is lost. Again, this makes sense, its a CONSOLE header now. But i need both functionalities.
Is there a way to support BOTH headers in one .exe?

Related

How to hide terminal shell on server application like Warp in Windows?

I have a small warp server project on Windows that listen to a particular port and do something whenever I send a command to it by REST (for example: POST http://10.10.10.1:5000/print). It's a small client for printing PDF / receipt directly from another computer.
It works. But my problem is when I had to package the whole project, the Rust compiler give me an executable file (.exe). The application displays a terminal window when I run it. I want this terminal to be hidden somehow.
I try to run the program as a windows service (by using NSSM). It doesn't work for me since I had to access the printer. Windows doesn't allow my app to access any devices or any other executable as a windows service. (The reasons are explained here: How can I run an EXE program from a Windows Service using C#?)
So I plan to run my app as a tray-icon application so user can control or close the app. (https://github.com/olback/tray-item-rs)
Unfortunately, I still cannot hide the app's terminal window.
Another solution that I found is hstart (https://www.ntwind.com/software/hstart.html). But I would like to use this as "the last resort" solution since many antivirus/windows defender mark it as a malware.
Do anyone know how to hide or get rid of it ?
After lot of searching, It turns out to be easier than I thought. Just add
#![windows_subsystem = "windows"]
on top of your main.rs file. (for rust > 1.18) and the terminal is gone.
These control the /SUBSYSTEM flag in the linker. For now, only
"console" and "windows" are supported.
When is this useful? In the simplest terms, if you're developing a
graphical application, and do not specify "windows", a console window
would flash up upon your application's start. With this flag, it
won't.
https://doc.rust-lang.org/reference/runtime.html#the-windows_subsystem-attribute
https://blog.rust-lang.org/2017/06/08/Rust-1.18.html
https://learn.microsoft.com/en-us/cpp/build/reference/subsystem-specify-subsystem?view=msvc-170

Is there a way to trick GUI applications in docker to think their window loaded?

I try to run an windows 10 application inside a windows servercore container.
The app can run without user input via COM-Interface (and without visible GUI), but it seems that it needs to load a hidden window in the background. When I start it on docker, the application log file indicates that it's stuck on starting this window.
Is there a way to make the app assume it successfully loaded the window?
All information I found so far was about users who want to see the GUI or about Linux/Windows combinations. None of that helped me.

Create a Windows executable that does not create a console window

I compiled a Windows GUI application with haskell-gi. Everything seems to be working fine. However, every time I double click on the executable in Windows Explorer to execute the program, Windows also creates a console window (i.e. a terminal) along with the main window of my application. Is it possible to ask Windows to not create the console window, which is how typical Windows GUI apps behave?
As per the ghc user guide, you can build a GUI-only application by adding the -optl-mwindows flag to your build.
Notice the warning in the link that says that in this mode using standard IO functions (putStrLn, getLine, or anything that reads from stdin or writes to stdout/stderr) will fail with an IOException on Windows.

On macOS how can I open a gui .app hidden or off screen?

I have a cross platform need to open a gui application programmatically, but keep it hidden from the user. Effectively, I want a command line driven interface to act as a wrapper over this gui app, and insulate the end user from seeing or interacting with it. The program is from a third party, I did not write it, and I can't edit it.
I can do this one way or another on Windows, on Linux, and (in theory) on older versions of Mac, but not the most recent ones. On Windows, I can use the native api ShellEx with a hide window parameter. It's very easy and straight forward. In Linux, I can can render a gui app to a virtual frame buffer (using xvfb).
On macOS, the open command has a --hide and --background option, but they don't have any effect (at least on this app...)
I tried changing the plist file and found that LSUIElement will hide the app from the docker, but it still shows up on the screen. LSUIPresentationMode=4 or 3 OUGHT to work for exactly this, but apparently that doesn't do anything anymore as of a few os versions ago...
I tried the approach of moving the .app off of the screen with AppleScript. That works, but you have to manually grant permissions for such a thing to occur via System Preferences. In prior versions of Mac, those permissions could be twiddled on the fly via sqlLite (so long as you had sudo rights), but now they blocked that too. You can only pull that off apparently through a process of disabling "SIP" and forcing a reboot. That is totally outside the realm of what I want.
I've tried using the xvfb approach on Mac (jumping through hoops to acquire the binary they use to include stock, and now dropped), but I'm not having luck with that. I don't think it's possible to direct a mac .app to another display is it? A .app does not render on X11 by it's nature right?
What other clever ways might there be to hide a third party app on a mac? (and that still works in most recent os versions!)

Win32 Console application or CLR -->windows form application?

I have to have a form as a gui,but i also need to write using win32 API as i need to create another process the moment the application is launched...
I created Win32 console-->empty project..then there was an option to add windows form as UI...Is it possible????...as i have chosen the base project to be win32 console application.
But i really need the form in the application.
C++/CLI is perfectly able to show a Windows Form in a console program, just as a windows console program is perfectly allowed to call CreateWindow. However, if you choose console as the output file mode then the console window is still going to show up to your user in addition to whatever forms you create.
You don't need to use the bare Windows API to create processes. See System.Diagnostics.Process.

Resources