2

How can I start an exe file with a fixed width, height, x and y positions from the command line?

I would expect something like this to work:

MyApp.exe --width 800 --height 600 --x 200 --y 0

Is there a set of universal parameters available for all applications?

gAMBOOKa
  • 361
  • 2
  • 8
  • 17
  • Possible duplicate of [Is there a way to resize a window to specific sizes (eg.800x600, 1024x768..)?](https://superuser.com/questions/18215/is-there-a-way-to-resize-a-window-to-specific-sizes-eg-800x600-1024x768) – Sandeep Oct 22 '18 at 12:59
  • @Sandeep All those answers require third-party tools. I am looking for a cmd only code. – gAMBOOKa Oct 22 '18 at 13:03
  • No universal built in option available as of now. I wrote some 8~10 lines of code with one Win API call and built one utility for my testing. – Sandeep Oct 22 '18 at 13:08
  • @Sandeep Would you mind sharing your code? Perhaps I, or someone else could have use for it. – gAMBOOKa Oct 22 '18 at 13:25
  • Not sure if it is good to post whole code as answer when it is not actually answering your question. I used C# and imported `MoveWindow` function from `user32.dll`. Called `Process.GetProcessesByName(appTitle)` to get process object and handle. And called `MoveWindow(process.MainWindowHandle, x, y, width, height, true)` to set windows position and size. You can get more details [here](https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-movewindow). – Sandeep Oct 22 '18 at 13:41
  • You can get some sample code [here](https://stackoverflow.com/questions/6484567/how-to-set-the-height-of-a-window-using-c) – Sandeep Oct 22 '18 at 13:43
  • Related: [Setting window size and position in PowerShell 5 and 6](https://superuser.com/q/1324007/376602) – JosefZ Oct 22 '18 at 13:54
  • If you wish only to use standard Windows applications, this is possible by using either PowerShell or VBScript. – harrymc Oct 22 '18 at 15:41

0 Answers0