Skip to content

Instantly share code, notes, and snippets.

@mavaddat
Last active June 20, 2020 20:00
Show Gist options
  • Save mavaddat/d450dcd63c9c4edd27124b045a777585 to your computer and use it in GitHub Desktop.
Save mavaddat/d450dcd63c9c4edd27124b045a777585 to your computer and use it in GitHub Desktop.
Powershell script to fix Adobe Photoshop CC memory issue #2416657
# Get the ID and security principal of the current user account
$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent()
$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID)
# Get the security principal for the Administrator role
$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator
# Check to see if we are currently running "as Administrator"
if ($myWindowsPrincipal.IsInRole($adminRole))
{
# We are running "as Administrator" - so change the title and background color to indicate this
$Host.UI.RawUI.WindowTitle = $myInvocation.MyCommand.Definition + "(Elevated)"
$Host.UI.RawUI.BackgroundColor = "DarkBlue"
clear-host
}
else
{
# We are not running "as Administrator" - so relaunch as administrator
# Create a new process object that starts PowerShell
$newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell";
# Specify the current script path and name as a parameter
$newProcess.Arguments = $myInvocation.MyCommand.Definition;
# Indicate that the process should be elevated
$newProcess.Verb = "runas";
# Start the new process
[System.Diagnostics.Process]::Start($newProcess);
# Exit from the current, unelevated, process
# exit
}
# Running code that needs to be elevated here
# A flexible way to determine the Photoshop path is below
$registryPath = $('Registry::'+$(Get-ChildItem -Path 'Registry::HKEY_CURRENT_USER\Software\Adobe\Photoshop\' -ErrorAction Inquire | Select-String -Pattern '[\w_\\]+\d+\.\d+'))
$name = "OverridePhysicalMemoryMB"
# Determine amount of installed RAM system memory in MB from cim_physical memory
$value = (Get-WmiObject -class "cim_physicalmemory" | Measure-Object -Property Capacity -Sum).Sum/ 1024 / 1024
IF([string]::IsNullOrEmpty( $(Get-ChildItem -Path 'Registry::HKEY_CURRENT_USER\Software\Adobe\Photoshop\' -ErrorAction SilentlyContinue | Select-String -Pattern '[\w_\\]+\d+\.\d+')) -or !(Test-Path $registryPath))
{
$host.ui.WriteErrorLine("Cannot find Adobe Photoshop installation location in the system registry.`r`nTry installing or re-installing Adobe Photoshop first.") | Out-Null
}
ELSE
{
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force -Verbose
}
Write-Host "Please press any key to continue..." | Out-Null
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")| Out-Null
@PhoeniixMan
Copy link

@mavaddat: thank you so so much........I had the problem titled "exception access violation" in CC 2018 version while trying to apply a function on a 'duplicate layer' of a photo........after creating this DWORD value now it's accessing about 1000MB in RAM and it's running with no error..........wish you good luck brother 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment