Posts

Showing posts with the label Registry

Automate Process Of Disk Cleanup Cleanmgr.exe Without User Intervention

Answer : The following Powershell script automates CleanMgr.exe. In this case, it removes temporary files and runs the Update Cleanup extension to purge superseded Service Pack Backup files (Windows 10 now does this automatically via a scheduled task). To automate other extensions, create a "StateFlags0001" property in the corresponding Registry key, as done in the New-ItemProperty lines. You will find the Registry key names in the "VolumeCaches" branch. As far as being silent, this script attempts to start CleanMgr.exe in a hidden window. However, at some point CleanMgr spawns new processes which are visible and must be waited on separately. Write-Host 'Clearing CleanMgr.exe automation settings.' Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\*' -Name StateFlags0001 -ErrorAction SilentlyContinue | Remove-ItemProperty -Name StateFlags0001 -ErrorAction SilentlyContinue Write-Host 'Enabling Upd...

Assign Command Output To Variable In Batch File

Answer : A method has already been devised, however this way you don't need a temp file. for /f "delims=" %%i in ('command') do set output=%%i However, I'm sure this has its own exceptions and limitations. This post has a method to achieve this from (zvrba) You can do it by redirecting the output to a file first. For example: echo zz > bla.txt set /p VV=<bla.txt echo %VV% You can't assign a process output directly into a var, you need to parse the output with a For /F loop: @Echo OFF FOR /F "Tokens=2,*" %%A IN ( 'Reg Query "HKEY_CURRENT_USER\Software\Macromedia\FlashPlayer" /v "CurrentVersion"' ) DO ( REM Set "Version=%%B" Echo Version: %%B ) Pause&Exit http://ss64.com/nt/for_f.html PS: Change the reg key used if needed.