Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 批处理文件以在IE浏览器中打开应用程序_Batch File_Internet Explorer - Fatal编程技术网

Batch file 批处理文件以在IE浏览器中打开应用程序

Batch file 批处理文件以在IE浏览器中打开应用程序,batch-file,internet-explorer,Batch File,Internet Explorer,为了检查应用程序与某些浏览器的兼容性,我制作了一个批处理文件,用IE打开一个URL @echo OFF IF EXIST "C:\Program Files (x86)\Internet Explorer\iexplore.exe" (GOTO :X86SUCCESS) ELSE GOTO :NOTSUCCESS :X86SUCCESS start "C:\Program Files (x86)\Internet Explorer\Iexplore.exe" "http://blah.com/b

为了检查应用程序与某些浏览器的兼容性,我制作了一个批处理文件,用IE打开一个URL

@echo OFF
IF EXIST "C:\Program Files (x86)\Internet Explorer\iexplore.exe" (GOTO :X86SUCCESS) ELSE GOTO :NOTSUCCESS
:X86SUCCESS
start "C:\Program Files (x86)\Internet Explorer\Iexplore.exe" "http://blah.com/blah"
goto END
:NOTSUCCESS
IF EXIST "C:\Program Files\Internet Explorer\iexplore.exe" (GOTO :X64SUCCESS) ELSE GOTO :NOTSUCCESS1
:X64SUCCESS
start "C:\Program Files\Internet Explorer\Iexplore.exe" "http://blah.com/blah"
goto END
:NOTSUCCESS1
:END

这通常应该在IE浏览器中打开URL,因为我们使用iexplore直接打开URL,但在某些机器上,这会打开其他浏览器,如Chrome,我不知道为什么,我猜这与默认浏览器设置有关,但既然我们打开IE,就不应该出现这种情况,有人能解释为什么会出现这种行为吗?即使默认浏览器不是IE,我如何始终在IE中打开URL

使用
start
命令将第一个参数解释为要在窗口标题栏中显示的标题。Internet Explorer的路径将设置为标题,URI将被shell执行。因此,将启动默认浏览器

您可以通过指定空标题字符串来防止出现这种情况:

setlocal
set "progFiles=%programfiles(x86)%"

if not defined progFiles (
  set "progFiles=%programfiles%"
)

start "" "%progFiles%\internet explorer\iexplore.exe" "http://blah.com/blah"
或者,您也可以这样启动Internet Explorer:

start iexplore "http://blah.com/blah"

正确地说,
start
将第一个引用的参数解释为窗口标题;因此:
start”“iexplore”…“
如果要执行的命令或程序也被引用,那么
start
似乎会将第一个引用的参数解释为窗口标题。由于
iexplore
不带引号,因此后面带引号的字符串将被视为第一个参数。