批处理文件如何运行程序并设置窗口的位置和大小? [英] How can a batch file run a program and set the position and size of the window?

查看:98
本文介绍了批处理文件如何运行程序并设置窗口的位置和大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有批处理文件,可以在我编写代码时为我设置桌面环境.该文件名为:SetEnv.cmd 并打开另外 3 个窗口:

I have batch file that sets up the desktop environment for me when I am writing code. The file is named: SetEnv.cmd and it opens 3 other windows:

  1. 设置为应用服务器部署目录的 Windows 资源管理器实例.
  2. 设置为写入我的部署文件的目录的第二个 Windows 资源管理器实例.
  3. 用于启动我的应用程序服务器的控制台窗口.

这里是SetEnv.cmd的内容:

Explorer /n,c:developjboss-4.2.3.GAserverdefaultdeploy
Explorer /n,c:developProjectMappingdeploy
cmd /c SetupEnvCmd.cmd

这里是SetupEnvCmd.cmd的内容:

cd C:developjboss-4.2.3.GAin
run

每次运行此程序时,我都必须浪费时间重新排列和调整窗口大小.我不想运行最小化的窗口,因为我在编写和测试代码时与每个窗口进行了多次交互.有什么方法可以控制从脚本中打开的窗口的位置和/或大小?

Every time I run this, I have to waste time rearranging and resizing the windows. I don't want to run the windows minimized, because I interact with each window many times while writing and testing code. Is there any way I can control the position and/or size of the windows that are opened from within the script?

推荐答案

尝试通过批处理文件从 VBS (Windows Script Host) 脚本启动您的程序.如果您的 VBS 如下所示:

Try launching your programs from VBS (Windows Script Host) script via the batch file. If your VBS looks like this:

'FILENAME: SetEnv.vbs
Set Shell = WScript.CreateObject("WScript.Shell")
Shell.Run "Explorer /n,c:developjboss-4.2.3.GAserverdefaultdeploy", 4, False
Shell.Run "Explorer /n,c:developProjectMappingdeploy", 4, False

4 表示以最近的大小/位置启动窗口.False 意味着它不会在执行脚本的下一行之前等待返回.不幸的是,这并不能让您完全控制您的确切窗口大小/位置,但它应该记住最后的大小/位置.

The 4 means to launch the window in its most recent size/position. False means it won't wait to return before executing the next line of your script. Unfortunately, this doesn't give you full control of your exact window size/positioning, but it should remember last size/positioning.

更多信息在这里:http://www.devguru.com/Technologies/wsh/quickref/wshshell_Run.html

所以你的新 SetEnv.cmd 可以是:

So your new SetEnv.cmd could be:

@echo off
REM note there's a difference between cscript and wscript
REM wscript is usually the default launcher
cscript SetEnv.vbs
cd C:developjboss-4.2.3.GAin
run

这篇关于批处理文件如何运行程序并设置窗口的位置和大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆