Link to home
Start Free TrialLog in
Avatar of skeed
skeed

asked on

batch file to force program window locations and sizes?

I have a batch file that opens up 6 putty ssh sessions automatically.  I would like to be able to specify the exact location and size of each and every putty window on my desktop upon execution of the batch file.  I can do this in Unix X-Windows using special parameters to the "xterm" command, but have had no luck figuring it out in Windows XP either through batch commands or putty session settings.
Avatar of sirbounty
sirbounty
Flag of United States of America image

Without coding this in another programming language, I don't think you'll get what you're after.
The closest I think you could get, though not automated, would be to right-click your task bar and click Tile Windows vertically/horizontally...

One other method I can think of..
Go to %systemroot%\system32 folder
Duplicate the cmd.exe file 6 times (one for each instance of the bat file).
cmd1.exe, cmd2.exe, etc

Now click start/run/cmd1.exe
Move the window to where you want the first bat file to appear
Click the menu bar (where it looks like a small C:\ prompt window - upper left corner) and choose properties.
From the layout tab, deselect "Let system position window".  Click Ok - you'll be asked to apply the settings to current window only or save for future sessions (choose the latter obviously).  Now repeat these procedures to the other 5 cmd sessions.

Now, when you run your bat file, precede the call line with the appropriate command session (cmd1.exe mybat1.bat)
I don't know exactly what layout you want, but once all 6 windows are opened, you can right click on an open area of the taskbar, or if the programs group together, you can right click on the group, and select tile horizontally or vertically to auto-position then on the screen.  I use this when opening pinging windows to all our routers.  Lets me see all the screens at once.
Avatar of skeed
skeed

ASKER

Sirbounty,

Thanks for your suggestions.  However, when I precede either the batch file or the commands within the batch file with "cmd1.exe", it merely loads the command prompt and not my batch file or specifically putty.exe.  Am I doing something wrong?  Thanks.
You'll need to create a shortcut to putty.exe for each one.  Then edit the shortcut to precede it with CMD1 {path to putty}\putty.exe
You can also right-click the desktop/new shortcut and navigate to it.
Then right-click the shortcut and choose properties to edit it as above...you'll need to repeat this for each instance, obviously.
Don't hesitate to ask if you need further clarification... :D
Avatar of skeed

ASKER

Sirbounty,

I have created the shortcut with the Target defined as:

C:\WINDOWS\system32\cmdtest1.exe C:\putty\putty.exe

and upon double clicking on it, it still merely loads the dos command line.

Am I doing something wrong?  Thanks.
I think I misread your prior post - place cmd1.exe in front of your calling batch file...
You might even try this way CMD1 /K myfile.bat
Avatar of skeed

ASKER

Sirbounty,

I am able to get it to do what I want using the CMD1 /C command, for the most part.  For some reason, the windows don't appear in the exact same location that I had set for them, but they are spaced apart in the appropriate manner, which is the main thing I was going for.  

On a side note, do you know what the equivalent of the Unix "sleep" command is in Windows batch programming?  

I'm going to give you all the points I can for helping me on this.  Thanks immensely for your time and advice.
ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial