VBS to Launch Custom Firefox Window and URL

2019-09-07 09:40发布

I have been mashing up some script to launch a portable version of Firefox with an URL linked to Webcams. My objective is to have 2 scripts using the same FF.exe but going to 2 different URLS/IP's. I am trying to rescrict the browser function by removing scroll bars.menus and status so only the webcam controls and view can be seen.

This is the current code but I seem to have made an error as now the URL is not displaying, only the default on launch. The sizing is perfect.

dim wshshell

FirefoxProfile = "Profile"
FirefoxPath = "C:\ADMIN\FF\FF.exe"
webappurl = "http://Domain.com"
Height = "870"
Width = "920"

Set wshshell = WScript.CreateObject("WScript.Shell")

wshshell.run """" & FirefoxPath & """ -P """ & FirefoxProfile & """ -Height """ & Height & """ -Width """ & Width & "" & webappurl

Set wshshell = Nothing
wscript.quit

Any help that you can provide or just a nudge in the right direction would be most appreciated. This is something else that I have found so maybe this could be used, Unfortunately I don't think that on it's own it's any use.

window.open('Domain.com',null,"height=100px,width=100px,status=0,toolbar=0,menubar=0,location=0");

Working code :

dim wshshell

Function qq(str)
qq = Chr(34) & str & Chr(34)
End Function

FirefoxProfile = "Profile"
FirefoxPath = "C:\ADMIN\FF\FF.exe"
webappurl = "172.22.111.8"
Height = "700"
Width = "920"
Status ="0"
Toolbar = "0"
Menubar = "0"

Set wshshell = WScript.CreateObject("WScript.Shell")

wshshell.run qq(FirefoxPath) & " -P " & qq(FirefoxProfile) _
& " -status " & qq(status) & " -Toolbar " & qq(toolbar) & " -menubar " & qq(menubar) _
& " -Height " & qq(Height) & " -Width " & qq(Width) _
& " " & webappurl

Set wshshell = Nothing
wscript.quit

1条回答
Root(大扎)
2楼-- · 2019-09-07 10:05

I suspect that your problem lies here:

wshshell.run ... & """ -Width """ & Width & "" & webappurl

The last "" in that instruction is just an empty string when you probably need a closing double quote followed by a space:

wshshell.run ... & """ -Width """ & Width & """ " & webappurl

I usually recommend using a quoting function to avoid quotefusion:

Function qq(str)
  qq = Chr(34) & str & Chr(34)
End Function

'...

wshshell.run qq(FirefoxPath) & " -P " & qq(FirefoxProfile) _
  & " -Height " & qq(Height) & " -Width " & qq(Width) _
  & " " & webappurl
查看更多
登录 后发表回答