在Win7和Win XP中关闭之前运行程序 [英] running a program before shutdown in Win7 and Win XP
问题描述
我知道有关于此的主题,我找到了这个主题: 如何安排任务在关闭时运行窗户 但是对我来说失败了.
I know that there are threads about this, I found this one: How to schedule a task to run when shutting down windows but it fails for me.
我在LabView中编写了一个小程序,并制作了一个exe.当我在正常的Windows操作中双击exe时,它运行完美(只需几秒钟即可完成).然后,我将exe放入批处理文件中,并将该批处理文件作为关闭脚本放入组策略中.结果是计算机在关机时挂起.它显示了几分钟的关闭屏幕,我必须重新启动PC才能重新启动它.我什至只在批处理文件中尝试了一个简单的文件复制命令,结果相同. 我究竟做错了什么? 任何提示都非常欢迎
I wrote a little program in LabView and made an exe out of it. It runs perfect when I double click the exe in normal windows operation (it takes just a few seconds to complete). Then I put the exe in a batch file and that batch file in the group policy as a shutdown script. The result is that the computer hangs when shuting down. It shows the shutdown screen for minutes and I have to power cycle the PC to start it again. I even tried only a simple file copy command in the batch file with the same result. What am I doing wrong? Any hints are greatly welcome
非常感谢
马丁
推荐答案
在关闭之前,我必须启用另一个选项来制作AutoHotKey脚本(我将其编译为.exe).该脚本将打开一个Excel文件并添加一些值.为了使其正常工作,我还必须启用指定组策略脚本的最大等待时间".
I had to enable another option to make my AutoHotKey script (which i compiled into an .exe) before shutdown. The script would open an Excel file and add some values. In order to make it work I also had to enable the "Specify maximum wait time for Group Policy Scripts".
只是为了更清楚地说明我在Windows 10中设置为英国英语所要做的所有步骤:
Just to make it more clear all the steps I had to do in Windows 10 set to UK English:
-
例如,通过在Windows开始"菜单中键入
- 打开编辑组策略.
- 转到本地组策略> Windows设置>脚本(启动/关闭)>关闭
- 在此处添加您的.exe.
- 通过点击确定关闭窗口.
- 转到本地组策略>管理模板>系统>脚本
- 启用在运行时显示处于关闭状态的指令.
- 启用指定组策略脚本的最长等待时间.我将我的时间设置为5000毫秒.
- Open Edit Group policy, by typing it into the Windows start menu for example.
- Go to Local Group Policy > Windows Setings > Scripts (Startup/Shutdown) > Shutdown
- Add your .exe here.
- Close window by clicking on OK.
- Go to Local Group Policy > Adminstrative Templates > System > Scripts
- Enable Display instructions in shutdown as they run.
- Enable Specify maximum wait time for Group Policy scripts. I set mine to 5000 ms.
每当我关机时,我首先会看到关机",然后屏幕变黑,它运行脚本(打开Excel),关闭Excel,然后真正关机.
Whenever I shutdown I first see the "Shutting down" and then the screen becomes black, it runs the script (opening Excel), closes Excel and then really shuts down.
这篇关于在Win7和Win XP中关闭之前运行程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!