Resize external command line window - winapi

What is better way to change size of command line windows in next case:
I started cmd process from my application
I set my widget as parent of cmd window
Now I need to resize command line window after widget resize event. But I have maximal size setted within my application.
Most examples used hStdOut of console, but how can (if can) I get it by cmd process id/window handle (now I haven't any other data)?
Also, sending of mode command in window is unsuitable - user can start any programm in command line window (e.g. run ssh client), so I can not be sure that command really will started.

Maybe that's an overkill, but why not to inject DLL which will use standard API to resize process console? If you started the process as you stated, you have process handle, so you can WaitForInputIdle and then Inject DLL which will call SetConsoleWindowInfo from it's DllMain. DLL can be very tiny, 1Kb or so without CRT.

Related

Compiled batch file run fullscreen

I have a batchfiles which basicly just "echo"s text into the cmd window. I compiled it to an exe but want it to be in full screen without borders and without taskbar.(Windows 7)
It should work without having to create a shortcut or any other settings like this.
It can be in the Batch code or the exe but it should start in fullscreen when - for example - I download and execute it on another computer without me having to set any settings.
Is that even possible in Batch?
If you mean running cmd.exe in fullscreen in Windows 7, it's basically impossible. Lots of people were complaining about it.
There are plenty "fake" fullscreen command lines.
You can use this one and run the batch there.

I want to prevent a window from opening when an application launches

I have a program the opens a window, reads a config file, then closes the window a fraction of a second later, then continues running in background. I want to be able to start this program one way or another without the window appearing in the first place.
Is there a way for me to launch the program (preferably on PC startup) but suppress any windows it creates?
I do not have the source code for the program in question. In that regard I am an end-user.
use a vbs script to open it:
set obj = createobject("wscript.shell")
obj.run "prog.exe",0,false
call that prog.vbs or whatever, and put it in:
"%userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\startup"

Is it possible to attach a non-console Win32 application to the invoking cmd shell?

When I have a Win32 non-console application (AFAIK, the console-ness of a Win32 app is linked into the exe), starting it from the console cmd.exe will return to the command prompt immediately, running the application "in the background" (o.c. it can have a GUI of sorts, or even open its own console window)
Is it possible in the non-console executable to detect that it was launched from cmd.exe and "attach" it to the launching cmd.exe?
And note that there are various questions/answers related to this, but it seems that this exact approach hasn't been investigated. (Maybe it's not possible like that.)
You can do this very easily. Simply pass ATTACH_PARENT_PROCESS to AttachConsole.
Whether or not the end result is sensible or practical is something I could not say. Both processes would read and write to the same console which could get pretty weird.

write to stdout with win32 gui app

If a win32 GUI app is run from the command line
e.g gfxexe.exe
first what is the simplest way to detect that it has been run from a command line
(cmd32.exe and possible other 3rd part command line apps).
second, and most importantly, if the app has been launched from the command line, how
can i print something to it.. e.g , this app can't be run from a command line.
Simplest Method I could come up with is. First, Create a console application, then Have your console application spawn your Window application, and Finally, Use Mapped Memory or some other form of Inter-Process Communication.

Full screen through batch command?

I have a batch script under Windows. When anyone will click on that script I want the command window to become full screen like we do by keyboard shortcut [Alt+Enter].
Can it be done automatically using any command in batch file?
In Windows XP, you need to start your program maximized (but not full screen) via "start /max" as follows:
start "Winow Title" /MAX "C:\batches\myfile.bat"
This command would be inside your original batch file, and call the real bath file.
I don't think there's a way to change the full screen-ness of an executing "cmd" command from within a batch file absent someone writing a special app to do so by emulating sending Alt+Enter to the parent process.
In Windows 7 (and probably Vista) you must run inside XP virtual machine for full screen mode.
There is none. You can write a small program doing so for you, though. There is the SetConsoleDisplayMode function.

Resources