【问题标题】:Batch file without error dialog没有错误对话框的批处理文件
【发布时间】:2015-04-28 15:47:49
【问题描述】:

我需要创建一个运行此命令的批处理文件

start chrome

问题是我不确定机器上是否安装了谷歌浏览器。我不能依赖注册表,因为我没有管理员权限。

如果我在未安装 Chrome 的机器上运行此命令,我会收到此错误对话框

(你看到“chromex”。我用这个名字来模拟软件的缺失)。

有没有办法避免显示这个对话框?

【问题讨论】:

    标签: windows google-chrome batch-file command


    【解决方案1】:

    下一个代码 sn-p 可能会有所帮助:

    @ECHO OFF >NUL
    SETLOCAL enableextensions
    SET "_chromePath="
    If DEFINED programfiles(x86) (
      For /F "tokens=*" %%G in (
        'where /R "%programfiles(x86)%" chrome.exe  2^>NUL'
      ) do SET "_chromePath=%%G"
    )
    If NOT DEFINED _chromePath (
      For /F "tokens=*" %%G in (
        'where /R "%programfiles%" chrome.exe  2^>NUL'
      ) do SET "_chromePath=%%G"
    )
    If DEFINED _chromePath (
      echo start "" "%_chromePath%"
    ) else (
      echo chrome.exe not found
    )
    

    注意start "" "%_chromePath%"echoed 仅用于调试目的。

    资源(必读):

    【讨论】:

      【解决方案2】:

      @echo 关闭

      echo Enter 1 启动 Chrome

      set /p input=在此处输入:

      如果 %input%==1 转到 chrome

      :铬

      echo 启动 chrome...

      启动 chrome.exe

      暂停

      【讨论】:

        【解决方案3】:

        对话框来自使用开始。直接执行文件可以看到命令提示符的等价物。

        'cat.exe' is not recognized as an internal or external command,
        operable program or batch file.
        

        通常会打开网站,窗口将使用用户选择的浏览器。

        Start "" www.microsoft.com
        start "" "c:\windows\help\mmc\htm\mmc_1.htm"
        

        我不能依赖注册表,因为我没有管理员权限。

        作为用户,您具有对大部分注册表的读取权限,并且可以覆盖每个用户的大多数设置和文件关联。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2010-11-12
          • 2018-04-21
          • 2017-10-26
          • 1970-01-01
          • 2022-01-05
          • 1970-01-01
          • 1970-01-01
          • 2015-05-25
          相关资源
          最近更新 更多