2

因此,我尝试了又尝试,但由于某种原因无法弄清楚这一点。

如何从所需目录而不是 cmd.exe 所在的 System32 目录运行任务。所以,当我安排任务并尝试运行它时..

命令提示符假设转到“c:\users\aaa\bbb\ccc”,然后传递参数。

相反,它从 c:\Windows\System32 开始并失败。

有人可以帮我吗?

对此,我真的非常感激。

谢谢你。

编辑 -

所以,现在我有一个 run.bat 文件,其中包含以下内容......

 C:\Users\aaa\bbb\ccc\dd (location to my testrunner.bat file) 
 testrunner.bat Scripts/all.suite website-address ie (command for the task I wanna perform)

 net stop schedule (since window is poping up and going away way to fast, I added this to stop it (not working))
4

1 回答 1

1
 type run.bat

 @echo off
 cd C:\Users\aaa\bbb\ccc\dd
 rem this will show all files in dir 
 rem is the file you're expecting listed?
 dir 

 rem notice how you can make comments with a leading rem(ark)

 @echo starting scripts\all.suite
 rem you have to change this to have the full path using Windows X:\dir\dir conventions
 c:\home\Scripts\all.suite website-address
 @echo done running scripts\all.suite website-address

 @echo shutting down
 net stop schedule

所以我仍然不清楚你的目标。我添加cd c:\...命令的原因是将 **C**change **D**irectory 到指定的路径。

这就是您所需要的,因此您可以“从所需目录而不是 System32 运行任务”。

从第一个@echo off到最后一个复制所有内容net stop并使用记事本,将其粘贴到文件中,修复命令名称和路径 website-urls 等,然后将该文件保存到 c:\temp\testrunner.bat。

打开 cmd.exe 窗口并测试脚本是否有效。只需粘贴c:\temp\testrunner.bat到 cmd-line 并按 Enter 键。如果可行,则在调度程序中创建一个条目以运行c:\temp\testrunner.bat。我不知道为调度程序运行脚本的细节,所以在输入屏幕上寻找线索。是否可以选择“现在”运行?

如果 .bat 文件不能从命令行运行,那么您必须先修复该文件,然后再尝试在调度程序中运行它。由于您的命令Scripts/all.suite website-address有点模糊,您最好发布一个新问题以寻求帮助以修复 .bat 文件并使用人们可以在家中的 PC 上使用的示例命令。

IHTH。

于 2014-08-29T01:12:30.050 回答