批处理文件:创建快捷方式并在Chrome中作为应用程序打开

时间:2016-01-25 16:27:15

标签: windows google-chrome batch-file shortcut

我正在尝试创建一个批处理文件,该文件使用图标创建网址的快捷方式,并在应用模式/全屏/自助服务终端中打开Chrome。这在尝试时按预期工作:

chrome.exe --app="http://app.mydomain.com" 

从批处理文件创建时,地址将在新窗口中打开(如果窗口打开,则打开新选项卡)。为什么我的快捷方式不是使用--app =“”部分? 下面的Create.bat文件:

@echo off 
@echo. 
@echo.
@echo.

::Set the application-specific string vars 
SET AppDescription=GRS
SET IconName=logo.ico
SET Shortcut_Name=GRS.url
SET URL_PATH="C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --new-window --start-fullscreen --app="http://app.mydomain.com" 

::Set the common string vars 
SET WORKING_PATH=%~dp0
SET ICONDEST=c:\ProgramData\%AppDescription%
SET LinkPath=%userprofile%\Desktop\%Shortcut_Name%

@echo. Copy Icon 
IF EXIST "%ICONDEST%" (GOTO _CopyIcon) 
mkdir "%ICONDEST%"
:_CopyIcon 
copy "%WORKING_PATH%%IconName%" "%ICONDEST%"

echo. 
echo. Create desktop shortcut... 
echo [InternetShortcut] > "%LinkPath%
echo URL=%URL_PATH% >> "%LinkPath%"
echo IDList= >> "%LinkPath%"
echo IconFile=%ICONDEST%\%IconName% >> "%LinkPath%"
echo IconIndex=0 >> "%LinkPath%"
echo HotKey=0 >> "%LinkPath%"
echo. 
echo. 
echo. 
echo. 
echo.You should now have a shortcut to %AppDescription% on your desktop...
echo. 
pause 

1 个答案:

答案 0 :(得分:0)

因为必须使用argrument来扩展: - app = ???

总而言之,.BAT文件我用来创建带有argruments的快捷方式:

@echo off
cd c:\
echo Set oWS = WScript.CreateObject("WScript.Shell") > CreateShortcut.vbs
echo sLinkFile = "%userprofile%\Desktop\POS.lnk" >> CreateShortcut.vbs
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> CreateShortcut.vbs
echo oLink.TargetPath = "C:\Program Files\Google\Chrome\Application\chrome.exe"  >> CreateShortcut.vbs
echo oLink.Arguments = "  http://localhost/  --kiosk  --kiosk-printing" >> CreateShortcut.vbs
   var pathe =  "C:\Program Files\Google\Chrome\Application";
echo oLink.WorkingDirectory = pathe >> CreateShortcut.vbs
echo oLink.Description = "My Application" >> CreateShortcut.vbs
echo oLink.IconLocation = "C:\logo.ico" >> CreateShortcut.vbs
echo oLink.Save >> CreateShortcut.vbs
cscript CreateShortcut.vbs
del CreateShortcut.vbs