How to set processor affinity from Batch File for Windows XP?

守給你的承諾、 提交于 2019-11-27 14:07:26

问题


I've got a dual processor machine and I would like to launch an executable via a batch file on both processors.

For example: (1) Launch Notepad.exe on Processor 1, and (2) Simultaneously, Notepad.exe on Processor 2

Currently, I'm using the following in my batch file, since my executable was "difficult" to launch and needed a return in order to run when launched: echo.|DoStuff.exe

Thus, I would like to launch it and have it run on each processor.

Thanks for any feedback provided.

P.S. I don't think "start" will work for me since I need to send in the return character to the executable as shown above with echo.

P.S.S. This is for a Windows XP solution. Thanks.


回答1:


Microsoft's Sysinternal's psexec's -a flag can set processor affinity on Windows XP:

Usage: psexec [\\computer[,computer2[,...] | @file][-u user [-p psswd]][-n s][-l][-s|-e][-x][-i
[session]][-c [-f|-v]][-w directory][-d][-][-a n,n,...] cmd [arguments]
     -a         Separate processors on which the application can run with
                commas where 1 is the lowest numbered CPU. For example,
                to run the application on CPU 2 and CPU 4, enter:
                "-a 2,4"

For example:

psexec -a 2 cmd /c "echo.|DoStuff.exe"



回答2:


start /affinity 1 notepad.exe

start /affinity 2 notepad.exe

(Windows7 has affinity for the start command, but XP does not. PSexec works though)




回答3:


  • This page talks about a free tool called XCPU you can use to launch and set affinity. However the link within doesn't work. Maybe a bit of googling can locate it for you.

  • And there is a simmillar tools here called runfirst.



来源:https://stackoverflow.com/questions/827754/how-to-set-processor-affinity-from-batch-file-for-windows-xp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!