简体   繁体   English

使用任务计划程序运行包含start / w命令的批处理文件

[英]Using Task Scheduler to run a batch file that contains the start /w command

I have a Windows XP virtual machine that I am using to run a legacy app. 我有一个用于运行旧版应用程序的Windows XP虚拟机。 I am using a limited user account. 我使用的是受限用户帐户。

I have created a batch file that I'd like to: 我创建了一个我想要的批处理文件:

  1. Start the legacy app 启动旧版应用
  2. Wait for the program in step 1 to close 等待步骤1中的程序关闭
  3. Shut down the computer 关闭电脑

So this is the code I am using (in this example, I am attempting to open notepad): 这是我正在使用的代码(在此示例中,我尝试打开记事本):

@ECHO OFF
start /w notepad
%windir%\system32\shutdown.exe -f -s -t 1

Because the legacy app needs to be run under an account with administrator privileges, I then manually created a scheduled task in Task Scheduler to run the batch file. 由于旧版应用程序需要在具有管理员特权的帐户下运行,因此我在Task Scheduler中手动创建了计划任务以运行批处理文件。 The scheduled task is set to run using an account named Admin that has administrator privileges. 计划的任务设置为使用名为Admin的帐户运行,该帐户具有管理员权限。

I am having a bit of an issue. 我有一个问题。 When the scheduled task runs, nothing appears on the screen. 当计划的任务运行时,屏幕上不显示任何内容。 However, I did notice that both cmd.exe and notepad.exe appear in Task Manager as processes running as the user Admin. 但是,我确实注意到cmd.exe和notepad.exe都以“管理员”用户身份运行在任务管理器中。

What am I doing wrong? 我究竟做错了什么? How can I accomplish what I'd like to do? 我该如何完成自己想做的事情? Thanks! 谢谢!

Sorry all, it was an issue with me not having Task Scheduler set up properly. 对不起,这是我没有正确设置Task Scheduler的问题。 I found this post which suggests to use the AT command to run the task interactively. 我发现这篇文章建议使用AT命令以交互方式运行任务。 This allows the Cmd window to be displayed when a batch file is run as a Scheduled Task. 当批处理文件作为计划任务运行时,这允许显示Cmd窗口。

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

相关问题 从任务计划程序运行批处理文件不适用于 java 命令 - Run a batch file from Task Scheduler is not working with a java command 如何使用批处理文件设置Task Scheduler Start in(可选)属性 - How to set task scheduler Start in(Optional) property using Batch file 如何使用任务计划程序和批处理文件运行SSIS包 - How to Run SSIS Package Using Task Scheduler and Batch File 获取批处理文件以在任务计划程序中运行 - Getting a batch file to run in task scheduler 使用 Windows 任务计划程序运行批处理文件 - Run a batch file with Windows task scheduler Windows 任务计划程序不启动批处理文件任务 - Windows Task Scheduler doesn't start batch file task Windows Task Scheduler可以运行批处理文件,但不能运行Winzip里面的命令 - Windows task scheduler can run batch file but not fire command inside for winzip 尽管报告任务已完成,任务计划程序仍无法运行批处理文件 - Task Scheduler fails to run batch file despite reporting task completed Windows Service-在Windows 2012 Server R2上使用任务计划程序使用批处理文件启动服务 - windows service - start service using batch file using task scheduler on windows 2012 server R2 在Windows 2008R2中使用任务计划程序运行时,不会从VBS文件中调用批处理文件 - batch file is not called from within VBS file when run using Task Scheduler in windows 2008R2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM