Solved

batch file to force program window locations and sizes?

Posted on 2004-04-22
9
1,189 Views
Last Modified: 2008-02-01
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.
0
Comment
Question by:skeed
  • 5
  • 3
9 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 10888151
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)
0
 
LVL 17

Expert Comment

by:Eagle6990
ID: 10889137
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.
0
 

Author Comment

by:skeed
ID: 10909827
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.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 10909936
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
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 67

Expert Comment

by:sirbounty
ID: 10909938
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
0
 

Author Comment

by:skeed
ID: 10912466
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.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 10914567
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
0
 

Author Comment

by:skeed
ID: 10948276
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.
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 10953845
Well, there's a SLEEP command in the windows environment as well - although it may be part of the resource kit.
Another trick some people use is a
Ping -N # 127.0.0.1 > nul
Replace # with the number of times you want it to ping (it's not 'exactly' a second per ping, but it's close)...

I did find the RKTools for Windows 2003 - sleep.exe should work for you from this package...
http://www.microsoft.com/downloads/details.aspx?FamilyID=9D467A69-57FF-4AE7-96EE-B18C4790CFFD&displaylang=en
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Disclosure: Use this tutorial only when no other options helps to get Windows XP running without any problems and you don't want to format the drive. The back up of the data is the responsible of the user, however there is a description of how t…
We have adopted the strategy to use Computers in Student Labs as the bulletin boards. The same target can be achieved by using a Login Notice feature in Group policy but it’s not as attractive as graphical wallpapers with message which grabs the att…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now