简体   繁体   English

任务计划程序-批处理文件-路径

[英]task scheduler - batch file - path

I have a batch file stored on my work network. 我的工作网络上存储了一个批处理文件。 When i go manually on the target folder and open my batch file it works just fine. 当我手动进入目标文件夹并打开我的批处理文件时,它工作正常。 Thus I wanted to put this command in my task scheduler, went on it and for its action, browsed my file, got a path Y:\\ and such However when i launch my scheduled task, i have a pop up saying windows doesn't find my bat file and my cmd writes "the path can not be found" 因此,我想将此命令放在任务计划程序中,继续执行该命令,并执行其操作,浏览我的文件,得到路径Y:\\,等等。但是,当我启动计划的任务时,我弹出一个窗口,说Windows没有找到我的蝙蝠文件,我的cmd写道“找不到路径”

I believe that is because with cmd it starts naturally on the C disk, thus as it is not on the right disk, the path is not found. 我相信这是因为cmd可以自然地在C磁盘上启动,因此由于它不在正确的磁盘上,因此找不到该路径。 A pushd to change disk from C to Y works afterwards, however i have to do that manually on cmd 推送将磁盘从C更改为Y后可以工作,但是我必须在cmd上手动进行操作

My question is, how can i handle my task scheduler to launch my file without having to create a copy of my file on the local disk? 我的问题是,如何处理任务计划程序以启动文件,而不必在本地磁盘上创建文件的副本? I would really like it to launch the bat file stored on work network. 我真的很想启动存储在工作网络中的bat文件。 Thought at first to write on my bat file the pushd line but well, the file is still stored on the network haha.. 起初以为在我的bat文件上写了推行,但是好了,该文件仍然存储在网络上哈哈。

Thanks for your help 谢谢你的帮助

Run a local batch file to map the network drive as Y 运行本地批处理文件以将网络驱动器映射为Y

net use y: \\server\blah

Then have it call your network batch file at Y: 然后让它在Y处调用您的网络批处理文件:

call y:\mybatch.bat

As task scheduler runs normally as a different user it doesn't have your drive mappings. 由于任务计划程序通常以其他用户身份运行,因此没有驱动器映射。


Alternatively call the batch file via it's unc path \\\\server\\blah\\mybatch.bat and then on the first line of the batch file pushd the unc path again 或者,通过其unc路径\\\\server\\blah\\mybatch.bat调用该批处理文件,然后在该批处理文件的第一行再次按unc路径

pushd \\server\blah\

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

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