在 Windows 登录窗口之前启动批处理脚本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5551003/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Launch batch script before windows login window
提问by Erem
I'm working on Windows Server 2003 and Windows server 2008. I would like to start a batch script just before the login window is displayed. I read about adding the script in the Group Policy editor (startup/shutdown) but it's not working (it worked for logon and logoff though).
我正在使用 Windows Server 2003 和 Windows Server 2008。我想在显示登录窗口之前启动批处理脚本。我阅读了有关在组策略编辑器(启动/关闭)中添加脚本的信息,但它不起作用(尽管它适用于登录和注销)。
An alternative would be to use the task scheduler service but it's not working either. Plus, I want to be able to see the results in a cmd window. That means the last alternative - creating a service to do the job - is not an option.
另一种方法是使用任务调度程序服务,但它也不起作用。另外,我希望能够在 cmd 窗口中看到结果。这意味着最后一个选择——创建一个服务来完成这项工作——不是一个选项。
Do you have any idea ?
你有什么主意吗 ?
Thanks.
谢谢。
回答by Denilson
Control Panel -> Scheduled Tasks -> < follow the prompts>
控制面板->计划任务-><按照提示操作>
Not as nice as a service, which you can start and stop through well-behaved commands, but if it is a service you want running at all times, it does the job.
不如服务好,您可以通过良好的命令启动和停止服务,但如果它是您希望始终运行的服务,它就可以完成工作。
回答by Denilson
Try adding your script as a user defined service
尝试将您的脚本添加为用户定义的服务
That way it will get executed before the login prompt;
这样它就会在登录提示之前执行;
http://support.microsoft.com/default.aspx?kbid=137890
http://support.microsoft.com/default.aspx?kbid=137890
Though this article says it can't be used for batch scripts, you can call the script from an executable.
尽管本文说它不能用于批处理脚本,但您可以从可执行文件中调用该脚本。