简体   繁体   English

批处理文件将不会按计划任务运行

[英]Batch file won't run as scheduled task

I have a batch file that creates a copy of an Access database as a backup and stores it on the network with a date stamp suffixed to the file name. 我有一个批处理文件,该文件创建Access数据库的副本作为备份并将其存储在网络上,并在文件名后加上日期戳。 This batch file runs fine on its own and also as a scheduled task while I am logged into the server (Windows server 2008 R2). 当我登录到服务器(Windows server 2008 R2)时,此批处理文件可以单独运行,也可以作为计划任务运行。 But despite trying many things I cannot get the scheduled task to run when I am not logged into the server. 但是,尽管尝试了很多事情,但我没有登录服务器时却无法使计划的任务运行。 I have tried configuring the scheduled task properties to run with the highest privileges, tried switching the settings of "run whether user is logged in or not" - and sore password options, tried amending the "Actions" tab by putting the path in the "Start In" parameter and only the batch file name in the "Program" parameter but still nothing works. 我尝试将计划的任务属性配置为以最高特权运行,尝试切换“无论用户是否登录都运行”的设置-并设置了密码选项,尝试通过将路径放入“ “开始于”参数,只有“程序”参数中的批处理文件名,但仍然无效。 What am I doing wrong here? 我在这里做错了什么?

I have this resolved - you live and learn as they say - and I learned something about batch scripting that I wasn't aware of. 我已经解决了这一问题-正如他们所说的那样,您可以生活和学习-并且我了解到一些我不了解的有关批处理脚本的信息。 Thank you TripeHound for assisting me in pinpointing that it was a network issue. 谢谢TripeHound协助我指出这是网络问题。

My batch file was copying the Access database to my company's "I:\\" drive, but I learned that while the user is NOT logged into the server the "I:\\" drive is NOT recognized and so I changed the I:\\ part to the actual server name path, ie "\\the_server\\the_drive$" and then it all worked 我的批处理文件正在将Access数据库复制到我公司的“ I:\\”驱动器中,但是我了解到,当用户未登录到服务器时,“ I:\\”驱动器无法识别,因此我更改了I:\\部分到实际的服务器名称路径,即“ \\ the_server \\ the_drive $”,然后一切正常

Check with following script replace the the folder name with your network folder name. 检查以下脚本,用您的网络文件夹名称替换文件夹名称。 Disable the "Run only if logged on option" and store the password using "Set password" option. 禁用“仅在登录后才运行”选项,并使用“设置密码”选项存储密码。

@echo off set folderName=D:\\omal\\BackupProjectDaily\\%date:~7,2%%date:~4,2%%date:~10,4% echo %folderName% if not exist %folderName% md %folderName% copy 1.txt %folderName%\\1-%date:~7,2%%date:~4,2%%date:~-4%.txt pause @echo off set folderName = D:\\ omal \\ BackupProjectDaily \\%date:〜7,2 %% date:〜4,2 %% date:〜10,4%回显%folderName%(如果不存在)%folderName%md%folderName %复制1.txt%folderName%\\ 1-%date:〜7,2 %% date:〜4,2 %% date:〜-4%.txt暂停

exit 出口

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM