d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Powershell Cpu Affinity Changer.
12Next
Closed New Topic New Poll
Member
Posts: 10,569
Joined: May 20 2009
Gold: 4,890.00
Feb 24 2014 11:13pm
Code
while($true)
{
$i
$ProcessIsRunning = Get-Process Game | Select-Object ProcessorAffinity
if($ProcessIsRunning -eq 1)
{
Write-Host "Sleeping for 600 Seconds because Game.exe is only using 1 core"
Start-Sleep -s 600
}
else
{
$instances = Get-Process Game
foreach ($i in $instances) {
$i.ProcessorAffinity=1
}
$Time = Get-Date
Get-Process Game | Select-Object ProcessorAffinity
Write-Host "Diablo 2 changed to Core 1 at $Time" -foregroundcolor DarkGreen -backgroundcolor Black
Start-Sleep -s 60
}
}


I'm a bit new... if you can't tell and want it to, if Game.exe is using core 1, Sleep, if not change to core 1 and sleep.
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Feb 24 2014 11:30pm
Right...
Member
Posts: 10,569
Joined: May 20 2009
Gold: 4,890.00
Feb 24 2014 11:31pm
Quote (Minkomonster @ Feb 25 2014 01:30am)
Right...


Right...?
Well it's doing it, just not checking before and just looping every 60 sec so i guess i'll leave it at that.
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Feb 24 2014 11:34pm
Firstly, its sleeping for 10 minutes if it is set, and 1 minute if it isn't. Secondly, why did you feel the need to post that?

This post was edited by Minkomonster on Feb 24 2014 11:35pm
Member
Posts: 10,569
Joined: May 20 2009
Gold: 4,890.00
Feb 24 2014 11:38pm
Quote (Minkomonster @ Feb 25 2014 01:34am)
Firstly, its sleeping for 10 minutes if it is set, and 1 minute if it isn't. Secondly, why did you feel the need to post that?


BECAUSE I NEED HALP
my diablo 2's take up like 40% cpu if i dont set them to only 1 cpu.

/e just make it check Game, see if its using cpu 1, if not change it to cpu 1.

This post was edited by NeMiiSiSWL on Feb 24 2014 11:39pm
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Feb 25 2014 12:04am
Not really sure what the protocol is on PowerShell. I know they look down on AutoIt.

Your $ProcessIsRunning var does not contain what you think it does. Also not sure why you are doing Select-Object ProcessorAffinity. This isn't doing what you think it does.

Code
$Process = Get-Process APP_NAME_HERE

if($Process.ProcessorAffinity -eq 1)
{
#ProcessorAffinity was equal to 1
}
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Feb 25 2014 04:34am
Quote (NeMiiSiSWL @ Feb 25 2014 01:38am)
BECAUSE I NEED HALP
my diablo 2's take up like 40% cpu if i dont set them to only 1 cpu.

/e just make it check Game, see if its using cpu 1, if not change it to cpu 1.



Should state what you need help with. We don't read minds.
Member
Posts: 10,569
Joined: May 20 2009
Gold: 4,890.00
Feb 25 2014 11:58am
Quote (AbDuCt @ Feb 25 2014 06:34am)
Should state what you need help with. We don't read minds.


i kinda of did?
Not to be rude but if you read it again, you'll understand what i want.
I want a script that changes d2 *IF ITS USING A CORE OTHER THAN 1* To 1, if its at 1 already it goes to sleep.
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Feb 25 2014 12:05pm
Quote (NeMiiSiSWL @ Feb 25 2014 01:58pm)
i kinda of did?
Not to be rude but if you read it again, you'll understand what i want.
I want a script that changes d2 *IF ITS USING A CORE OTHER THAN 1* To 1, if its at 1 already it goes to sleep.


No you typed some nonsensical 10 year old boy sentence ("BECAUSE I NEED HALP") and a quick blurb about what you are trying to do only after Minko poked and probed you about what you were even attempting to do. Also forcing the game to sleep is not a solution this will cause frame drops and periods of unresponsiveness most likely causing disconnections from battle.net.
Member
Posts: 10,569
Joined: May 20 2009
Gold: 4,890.00
Feb 25 2014 12:19pm
Quote (AbDuCt @ Feb 25 2014 02:05pm)
No you typed some nonsensical 10 year old boy sentence ("BECAUSE I NEED HALP") and a quick blurb about what you are trying to do only after Minko poked and probed you about what you were even attempting to do. Also forcing the game to sleep is not a solution this will cause frame drops and periods of unresponsiveness most likely causing disconnections from battle.net.


The game isnt sleeping the script is....
@.@

Code
$i = 0
$ary = 1..500000000

Do
{
$ary[$i]
$i=1
$Process = Get-Process Game

if($Process.ProcessorAffinity -ne 1)
{
Write-Host "#ProcessorAffinity was not equal to 1, changing to 1."
$instances = Get-Process Game
foreach ($i in $instances)
{
$i.ProcessorAffinity=1
sleep 2
$time = Get-Date
Write-Host "Diablo 2 changed to core 1 at $time"
}
}
} until ($i -eq 500000000)


What i have so far.

however it still doesnt detect the core it is on, and then change it.
it just changes it no matter what.
Go Back To Programming & Development Topic List
12Next
Closed New Topic New Poll