![如何强制 Windows Server 2008 启动可执行文件的新版本而不是旧版本?](https://linux22.com/image/604677/%E5%A6%82%E4%BD%95%E5%BC%BA%E5%88%B6%20Windows%20Server%202008%20%E5%90%AF%E5%8A%A8%E5%8F%AF%E6%89%A7%E8%A1%8C%E6%96%87%E4%BB%B6%E7%9A%84%E6%96%B0%E7%89%88%E6%9C%AC%E8%80%8C%E4%B8%8D%E6%98%AF%E6%97%A7%E7%89%88%E6%9C%AC%EF%BC%9F.png)
我们有一台使用终端服务的 Windows Server 2008。当用户登录时,网络共享上的可执行文件会启动,其中包含一些用于执行各种任务的热键和宏。
每当我更新可执行文件时,我必须在任务管理器中为每个用户关闭该程序的所有副本,然后新版本的可执行文件才会启动。如果我不这样做,启动可执行文件将打开旧版本,而不是新版本。
有没有更有效的方法让 Windows 打开新版本的可执行文件而不是旧版本?
通过任务管理器并在每个会话中点击结束任务是极其繁琐的,而且它会阻止每个人的宏工作,直到他们发现需要手动重新启动该程序。
答案1
您可以使用 taskkill.exe 来终止所有实例,而不是使用任务管理器:
taskkill.exe myapplicationname.exe
TASKKILL [/S system [/U username [/P [password]]]]
{ [/FI filter] [/PID processid | /IM imagename] } [/T] [/F]
Description:
This tool is used to terminate tasks by process id (PID) or image name.
Parameter List:
/S system Specifies the remote system to connect to.
/U [domain\]user Specifies the user context under which the
command should execute.
/P [password] Specifies the password for the given user
context. Prompts for input if omitted.
/FI filter Applies a filter to select a set of tasks.
Allows "*" to be used. ex. imagename eq acme*
/PID processid Specifies the PID of the process to be terminated.
Use TaskList to get the PID.
/IM imagename Specifies the image name of the process
to be terminated. Wildcard '*' can be used
to specify all tasks or image names.
/T Terminates the specified process and any
child processes which were started by it.
/F Specifies to forcefully terminate the process(es).
/? Displays this help message.
Filters:
Filter Name Valid Operators Valid Value(s)
----------- --------------- -------------------------
STATUS eq, ne RUNNING |
NOT RESPONDING | UNKNOWN
IMAGENAME eq, ne Image name
PID eq, ne, gt, lt, ge, le PID value
SESSION eq, ne, gt, lt, ge, le Session number.
CPUTIME eq, ne, gt, lt, ge, le CPU time in the format
of hh:mm:ss.
hh - hours,
mm - minutes, ss - seconds
MEMUSAGE eq, ne, gt, lt, ge, le Memory usage in KB
USERNAME eq, ne User name in [domain\]user
format
MODULES eq, ne DLL name
SERVICES eq, ne Service name
WINDOWTITLE eq, ne Window title
NOTE
----
1) Wildcard '*' for /IM switch is accepted only when a filter is applied.
2) Termination of remote processes will always be done forcefully (/F).
3) "WINDOWTITLE" and "STATUS" filters are not considered when a remote
machine is specified.
Examples:
TASKKILL /IM notepad.exe
TASKKILL /PID 1230 /PID 1241 /PID 1253 /T
TASKKILL /F /IM cmd.exe /T
TASKKILL /F /FI "PID ge 1000" /FI "WINDOWTITLE ne untitle*"
TASKKILL /F /FI "USERNAME eq NT AUTHORITY\SYSTEM" /IM notepad.exe
TASKKILL /S system /U domain\username /FI "USERNAME ne NT*" /IM *
TASKKILL /S system /U username /P password /FI "IMAGENAME eq note*"