How can a batch file run a program and set the position and size of the window?

前端 未结 6 754
半阙折子戏
半阙折子戏 2020-11-28 06:18

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:

6条回答
  •  长情又很酷
    2020-11-28 06:35

    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:\develop\jboss-4.2.3.GA\server\default\deploy", 4, False
    Shell.Run "Explorer /n,c:\develop\Project\Mapping\deploy", 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.

    More info here: http://www.devguru.com/Technologies/wsh/quickref/wshshell_Run.html

    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:\develop\jboss-4.2.3.GA\bin
    run
    

提交回复
热议问题