使用开始Chrome浏览器从URL下载文件

时间:2018-09-22 11:28:49

标签: batch-file

我有一个批处理文件,该文件打开一个URL以下载一个csv文件,然后我需要移动该csv形式的downloads文件夹,然后将其重命名为另一个。

我拥有的是:

@echo off

SET CCDIR=C:\Users\(username)\Desktop
SET LOADDIR=C:\Users\(username)\Downloads

ECHO ***************************************************************************
ECHO  Downloading the file
ECHO ***************************************************************************

start chrome (URL string)

:NEXT

ECHO ***************************************************************************
ECHO  Move CSV file from Downloads folder to Desktop
ECHO ***************************************************************************

move %LOADDIR%\*(file string)* %CCDIR%
ren %CCDIR%\*(file string)* (new file name)

我想在同一个蝙蝠中执行所有操作,但是只是开始chrome正在运行,蝙蝠忽略了移动和回合。

我该怎么做?

1 个答案:

答案 0 :(得分:0)

根据我的评论,您可以尝试使用本示例使用Certuil command下载文件

@echo off
Title Downloading a file using Certutil Command
Mode 70,5 & color 0A
SET CCDIR=%userprofile%\Desktop
SET LOADDIR=%userprofile%\Downloads
set "url=https://download.sysinternals.com/files/PSTools.zip"
echo(
ECHO   ******************************************************************
ECHO          Please wait a while ... Downloading the file ...
ECHO   ******************************************************************
Call :download %url% %LOADDIR%
Rem Moving the downloaded file from the folder Downloads to Desktop
move /Y "%file%" "%CCDIR%\">nul
Rem Open the desktop folder with explorer
Explorer "%CCDIR%\"
goto :eof
::--------------------------------------------
:Download <Url> <File>
Set url="%~1"
Set file=%2\%~nx1
certutil.exe -urlcache -split -f %url% %file%>nul
Rem Deleting cache
certutil -urlcache "%~1" delete>nul
Rem Check referenced urlcache is deleted
certutil.exe -v -urlcache -split "%~1">nul
exit /b
::--------------------------------------------