Git Product home page Git Product logo

Comments (3)

skrimix avatar skrimix commented on May 30, 2024 1

Adding -ldflags -H=windowsgui to go build command produces a GUI executable and Windows stops allocating console automatically. I tested with NSSM and sol is working without spawning conhost

from sleep-on-lan.

SR-G avatar SR-G commented on May 30, 2024

I see your point, but i have no idea how to achieve that.

Do you have any evidence that it's possible / any clue about how to technically speaking achieve this ?

Because as far as i can tell, a windows program either has to be a "form-based" application (with a GUI), either a "console" application (launchable in a standalone way - and here of course with a console, or through a service machanism (here, just as a proposal, with the external tool NSSM).

And have you tried this, by the way, per the NSSM documentation ? (@see https://nssm.cc/usage)

Console window
As of version 2.22, nssm will by default create a new console window for the application. This allows some programs to work which would otherwise fail, such as those which expect to be able to read user input. The console window can be disabled if it is not needed by setting the integer (REG_DWORD) value AppNoConsole under HKLM\System\CurrentControlSet\Services\servicename\Parameters to a non-zero value.

Otherwise for reference, i have not found a lot of informations about that topic in golang :

  • this is about hiding the console (but it will still be visible inside TaskManager with a conhost.exe extra line, i would say) : https://github.com/ifrstr/hideconsole/blob/master/hideconsole_win.go
  • there is a "DETACHED_PROCESS" pure-indows property, used for example here, but not clear if this would work : https://github.com/tinygo-org/tinygo/blob/release/util_windows.go
  • there are huge golang frameworks like "https://github.com/judwhite/go-svc" (allowing to have the binaries themselves being able to register as a windows service), but a) i don't know if that would work anyway (about not having a "conhost.exe" associated process) and b) i really don't like this approach, which is not at all going in the good direction (wrapping as a service should be done around the processes ("unix philosophy"), and not with a lot of code inside the processes themselves)

from sleep-on-lan.

xtcrefugee avatar xtcrefugee commented on May 30, 2024

Sorry, I have no experience with Go so I don't know if it's possible within that framework.

The closest thing I can think of, with an app that stays resident but has no console window, would be something like a compiled AutoHotkey script. Those have a system tray icon to (minimally) just exit the program. I don't know if that's something you'd consider replicating here or not.

Unfortunately I'd already tried setting NSSM to not have a console window (it's also a checkbox in NSSM's interactive UI) but sol still spawns one. I also tried redirecting stdin and stdout to <NUL and >NUL respectively, but the console process still starts.

from sleep-on-lan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.