You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering if it was possible to run a compiled deno binary in background on windows, after some research and discussion on the official Deno Discord, I found that yes indeed it was.
So I made an implementation that works, only change the subsystem to "Windows" (because I don't think it would be useful to add more but we never know)
(I am new to Rust, you can probably do a better implementation !)
letmut standalone_bin = final_bin;#[cfg(windows)]{use byteorder::{ReadBytesExt,LittleEndian,WriteBytesExt};// This is just for adding support for Windows background process into compiled binaries// By default the Deno.exe binary is set to Console,// while this implementation may be junky it worksif subsystem == "windows"{letmut reader = std::io::Cursor::new(&mut standalone_bin);// We Read until the PE Pointer
reader.seek(SeekFrom::Start(0x3C))?;let pe_header_start = reader.read_u32::<LittleEndian>()?;//We go 92 bytes further to reach the Subsysem fieldlet subsys_offset = pe_header_start + 92;
reader.seek(SeekFrom::Start(subsys_offset asu64))?;let subsys = reader.read_u16::<LittleEndian>()?;//can be tweaked to add more subsytemsif subsys != 0x2{
reader.seek(SeekFrom::Start(subsys_offset asu64))?;
reader.write_u16::<LittleEndian>(0x2)?;}}}
This is added at the end of the write_standalone_binary function, which also now has the subsystem param, that contains the value set in the flag deno compile -A -s windows app.ts
I made this so it can works with multiple options 🤷♂️ but it is not really useful.
This implementation can be useful for app that uses Webview (best example i have), I have been trying to work with Wry from the Tauri project, in order to implement Deno bindings for a personal project, with this it can run on windows in background and can display a Browser (or any really) window without showing up a new CMD.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello fellow denodevs
I was wondering if it was possible to run a compiled deno binary in background on windows, after some research and discussion on the official Deno Discord, I found that yes indeed it was.
So I made an implementation that works, only change the subsystem to "Windows" (because I don't think it would be useful to add more but we never know)
(I am new to Rust, you can probably do a better implementation !)
This is added at the end of the
write_standalone_binaryfunction, which also now has thesubsystemparam, that contains the value set in the flagdeno compile -A -s windows app.tsI made this so it can works with multiple options 🤷♂️ but it is not really useful.
This implementation can be useful for app that uses Webview (best example i have), I have been trying to work with Wry from the Tauri project, in order to implement Deno bindings for a personal project, with this it can run on windows in background and can display a Browser (or any really) window without showing up a new CMD.
I found the solution in this thread #11638
Beta Was this translation helpful? Give feedback.
All reactions