[英]Chrome won't open from batch file in Windows Task Scheduler
I have a batch file that opens a webpage in chrome, and then moves and renames a file that is downloaded from the website. 我有一个批处理文件,该文件在chrome中打开网页,然后移动并重命名从网站下载的文件。 The batch file works when I manually run it.
当我手动运行该批处理文件时,它可以工作。 The file does not work when I set the file to run in the windows task scheduler
当我将文件设置为在Windows Task Scheduler中运行时,该文件不起作用
set date=%DATE:~10,4%_%DATE:~4,2%_%DATE:~7,2%
chrome "http://www.example.com/download_page" >>debug.log 2>&1
timeout 10
move "C:\Users\user\Downloads\export.csv" "C:\path\to\moved\file%date%.csv" >>debug.log 2>&1
Here is the error message that shows up in debug.log 这是debug.log中显示的错误消息
[21396:15752:0317/101540:ERROR:process_singleton_win.cc(335)] Lock file can not be created!
[21396:15752:0317/101540:ERROR:process_singleton_win.cc(335)]无法创建锁定文件! Error code: 32 [21396:15752:0317/101540:ERROR:chrome_browser_main.cc(1356)] Failed to create a ProcessSingleton for your profile directory.
错误代码:32 [21396:15752:0317/101540:ERROR:chrome_browser_main.cc(1356)]无法为您的配置文件目录创建ProcessSingleton。 This means that running multiple instances would start multiple browser processes rather than opening a new window in the existing process.
这意味着运行多个实例将启动多个浏览器进程,而不是在现有进程中打开新窗口。 Aborting now to avoid profile corruption.
现在中止以避免配置文件损坏。
I recommend you using built-in tools such as bitsadmin
, though some people whine about how it's depreciated and the next thing you'll see is powershell/vbs alternative. 我建议您使用诸如
bitsadmin
类的内置工具,尽管有些人抱怨它如何贬值,接下来您将看到powershell / vbs替代品。
Bitsadmin downloads it for you so you'd need no timeout 10
if you won't run it in another instance. Bitsadmin会为您下载它,因此如果您不会在其他实例中运行它,则无需
timeout 10
。 Sometimes it can take a second to get to the full download speed. 有时可能需要一秒钟才能达到完整的下载速度。 Only disadvantage I see is automatic
cls
of your cmd screen, therefore the way with start bitsadmin
and then you could check for %errorlevel% equ 0
for succesful download. 我看到的唯一缺点是cmd屏幕的自动
cls
,因此使用start bitsadmin
的方式,然后您可以检查%errorlevel% equ 0
是否成功下载。
bitsadmin.exe /transfer "<name_of_job>" "<url>" "<where to save>"
This way even your move
seems unnecessary. 这样,即使您的
move
似乎都是不必要的。 Check bitsadmin /?
检查
bitsadmin /?
for more info. 有关更多信息。
I stopped trying to run Chrome in the windows task scheduler. 我停止尝试在Windows Task Scheduler中运行Chrome。 Instead I installed the chrome extension Crontabs.
相反,我安装了Chrome扩展程序Crontabs。 I setup Crontabs to open the page at a certain time then close the tab after a few minutes.
我将Crontabs设置为在特定时间打开页面,然后在几分钟后关闭该选项卡。 I continued to use the Windows Task Scheduler to move the downloaded file.
我继续使用Windows Task Scheduler移动下载的文件。 I had to disable sleep/hibernate for this to work while I am away from my computer.
当我离开计算机时,必须禁用睡眠/休眠才能正常工作。
http://www.crontabs.org/ http://www.crontabs.org/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.