Hide CMD windows when running some program via Run() on windows

Discuss any general programming issues here
Post Reply
amiga23
Posts: 33
Joined: Thu Jan 30, 2014 6:01 pm

Hide CMD windows when running some program via Run() on windows

Post by amiga23 »

When I use the Run() method, on windows always a CMD window is opened, while the exe called by Run() is running. Same size and same position as opening cmd.exe.
Is there a way to suppress these windows or, minimize them, or at least have them in background?
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Hide CMD windows when running some program via Run() on windows

Post by airsoftsoftwair »

It's currently not possible but I think it makes sense to add a new tag to Run() and Execute() which allows the suppression of that window. Until then, you can workaround the problem by simply defining a "RunOutput" event handler that catches the program's output. This should make the console window go away, e.g. like this:

Code: Select all

InstallEventHandler({RunOutput = Function(msg) EndFunction})
Run("test.exe")
amiga23
Posts: 33
Joined: Thu Jan 30, 2014 6:01 pm

Re: Hide CMD windows when running some program via Run() on windows

Post by amiga23 »

For RunOutput I do already use an EventHandler and it gets the output correctly, but still the window opens.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Hide CMD windows when running some program via Run() on windows

Post by airsoftsoftwair »

What kind of program is it that you're trying to run? There are also Windows programs which open a console by default. In that case it's impossible to suppress it. You can easily check if that's the case by running the program from cmd.exe or PowerShell. Does it open a new console or does it show its output in cmd.exe or PowerShell?
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Hide CMD windows when running some program via Run() on windows

Post by airsoftsoftwair »

Code: Select all

- New [Windows]: Execute() and Run() accept a new "Hide" tag in their optional table argument now; if this
  is set to TRUE, console programs on Windows won't open their console window
 
User avatar
Juan Carlos
Posts: 887
Joined: Mon Sep 06, 2010 1:02 pm

Re: Hide CMD windows when running some program via Run() on windows

Post by Juan Carlos »

airsoftsoftwair wrote: Sun Aug 20, 2023 3:38 pm

Code: Select all

- New [Windows]: Execute() and Run() accept a new "Hide" tag in their optional table argument now; if this
  is set to TRUE, console programs on Windows won't open their console window
 
Good news to make a Trojan or Spyware program with Hollywood. :D :lol:
User avatar
Allanon
Posts: 732
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: Hide CMD windows when running some program via Run() on windows

Post by Allanon »

I don't know if the fix added will remove the black windows, I used the tool "nircmd.exe" with the syntax

Code: Select all

nircmd.exe exec hide <command_to_execute>
to hide that annoying window, you can read more about it here :

https://nircmd.nirsoft.net/exec.html

Sometimes it's tricky to hide cmd windows even with this tool.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Hide CMD windows when running some program via Run() on windows

Post by airsoftsoftwair »

Allanon wrote: Tue Aug 22, 2023 11:57 am Sometimes it's tricky to hide cmd windows even with this tool.
I think Hollywood does pretty much the same as nircmd so if nircmd can hide the window Hollywood should be able to do so too now :) Of course, the window can't be hidden for programs that really enforce having a window but normally they shouldn't do that. It's a Windows thing that it always opens a console window for console program and this window can be hidden now by Hollywood.
User avatar
Allanon
Posts: 732
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: Hide CMD windows when running some program via Run() on windows

Post by Allanon »

airsoftsoftwair wrote: Mon Aug 28, 2023 10:42 pm
Allanon wrote: Tue Aug 22, 2023 11:57 am Sometimes it's tricky to hide cmd windows even with this tool.
I think Hollywood does pretty much the same as nircmd so if nircmd can hide the window Hollywood should be able to do so too now :) Of course, the window can't be hidden for programs that really enforce having a window but normally they shouldn't do that. It's a Windows thing that it always opens a console window for console program and this window can be hidden now by Hollywood.
Well, that's a great news! Thank you :)
I've fighted with those black windows for years :lol:
Post Reply