0

I want to create a batch file which will open one application and one link. The idea is to use this batch file in the shortcut file on desktop so that on one click the application and the URL link example www.google.com should open but the browser size should be custom i.e for example 600*600

Please suggest

@echo off

start test.exe

start www.google.com

exit
Hackoo
  • 18,337
  • 3
  • 40
  • 70
samir
  • 23
  • 1
  • 3

2 Answers2

0

The start command can start windows maximized, but not scaled to a specific size. And browser security will prevent you from using JavaScript within the target web page's code to resize the client window.

Best bet is to use the InternetExplorer.Application COM object to interact with an Internet Explorer window, rather than attempting to manipulate the user's unknown default browser.

Here's one possible solution. Save it with a .bat extension and run it to see what happens.

<!-- // batch / HTA hybrid script

@echo off

start calc.exe

rem // invoke HTA chimera for VBScript
mshta "%~f0"

rem // end main runtime
goto :EOF

// HTA chimera -->
<script language="VBscript">

Set IE = CreateObject("InternetExplorer.Application")

IE.navigate2 "http://stackoverflow.com/"
IE.width = 600
IE.height = 600
IE.visible = true

close()

</script>

You could also interact with the InternetExplorer.Application COM object with a JScript hybrid or Powershell script if you prefer.

rojo
  • 24,000
  • 5
  • 55
  • 101
  • Thanks it works but when I try to move the IE window to left using IE.margin-left = 300px it is not taking effect. Is it not the right way to move the IE window? – samir Jun 29 '15 at 13:24
  • That's a Windows API thing, not a DOM thing. You'll have to use [something a little more advanced](http://stackoverflow.com/a/16126938/1683264) for that sort of thing. – rojo Jun 29 '15 at 13:48
  • @samir If my answer was helpful, please consider marking it as accepted. [See this page](http://meta.stackexchange.com/questions/5234/) for an explanation of why this is important. – rojo Jun 29 '15 at 14:47
  • In the above code you provided what if the browser should be full screen. I tried with IE.width and IE.height as 1100 and 1000 but it doesn't works consistently.. i.e it worked for me but not on some other systems in network. – samir Jul 15 '15 at 09:03
0

@samir, when you assign value on IE.width and IE.height, make sure you are not setting anything higher than the resolution of the screen.

I hope this helps.