Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
fuss:dos [2017/02/22 18:30] – external edit 127.0.0.1fuss:dos [2023/12/16 03:33] (current) – [Reload / Refresh Environment Variables] office
Line 21: Line 21:
 del PATH /A:H  /S  del PATH /A:H  /S 
 </code> </code>
 +
 +====== Blank the Screen from Command Line ======
 +
 +The command:
 +<code dos>
 +ping -n 6 127.0.0.1 > nul && explorer C:\Windows\System32\scrnsave.scr
 +</code>
 +
 +will blank the screen in ''6'' seconds.
 +
 +Note that ''C:\Windows\System32\scrnsave.scr'' must exist and must be invoked via ''explorer''.
 +
 +====== Reload / Refresh Environment Variables ======
 +
 +The following script from chocolatey reloads the environment variables on Windows.
 +<code dos>
 +@echo off
 +::
 +:: RefreshEnv.cmd
 +::
 +:: Batch file to read environment variables from registry and
 +:: set session variables to these values.
 +::
 +:: With this batch file, there should be no need to reload command
 +:: environment every time you want environment changes to propagate
 +
 +::echo "RefreshEnv.cmd only works from cmd.exe, please install the Chocolatey Profile to take advantage of refreshenv from PowerShell"
 +echo | set /p dummy="Refreshing environment variables from registry for cmd.exe. Please wait..."
 +
 +goto main
 +
 +:: Set one environment variable from registry key
 +:SetFromReg
 +    "%WinDir%\System32\Reg" QUERY "%~1" /v "%~2" > "%TEMP%\_envset.tmp" 2>NUL
 +    for /f "usebackq skip=2 tokens=2,*" %%A IN ("%TEMP%\_envset.tmp") do (
 +        echo/set "%~3=%%B"
 +    )
 +    goto :EOF
 +
 +:: Get a list of environment variables from registry
 +:GetRegEnv
 +    "%WinDir%\System32\Reg" QUERY "%~1" > "%TEMP%\_envget.tmp"
 +    for /f "usebackq skip=2" %%A IN ("%TEMP%\_envget.tmp") do (
 +        if /I not "%%~A"=="Path" (
 +            call :SetFromReg "%~1" "%%~A" "%%~A"
 +        )
 +    )
 +    goto :EOF
 +
 +:main
 +    echo/@echo off >"%TEMP%\_env.cmd"
 +
 +    :: Slowly generating final file
 +    call :GetRegEnv "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" >> "%TEMP%\_env.cmd"
 +    call :GetRegEnv "HKCU\Environment">>"%TEMP%\_env.cmd" >> "%TEMP%\_env.cmd"
 +
 +    :: Special handling for PATH - mix both User and System
 +    call :SetFromReg "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" Path Path_HKLM >> "%TEMP%\_env.cmd"
 +    call :SetFromReg "HKCU\Environment" Path Path_HKCU >> "%TEMP%\_env.cmd"
 +
 +    :: Caution: do not insert space-chars before >> redirection sign
 +    echo/set "Path=%%Path_HKLM%%;%%Path_HKCU%%" >> "%TEMP%\_env.cmd"
 +
 +    :: Cleanup
 +    del /f /q "%TEMP%\_envset.tmp" 2>nul
 +    del /f /q "%TEMP%\_envget.tmp" 2>nul
 +
 +    :: capture user / architecture
 +    SET "OriginalUserName=%USERNAME%"
 +    SET "OriginalArchitecture=%PROCESSOR_ARCHITECTURE%"
 +
 +    :: Set these variables
 +    call "%TEMP%\_env.cmd"
 +
 +    :: Cleanup
 +    del /f /q "%TEMP%\_env.cmd" 2>nul
 +
 +    :: reset user / architecture
 +    SET "USERNAME=%OriginalUserName%"
 +    SET "PROCESSOR_ARCHITECTURE=%OriginalArchitecture%"
 +
 +    echo | set /p dummy="Finished."
 +    echo .
 +</code>
 +
 +====== Kill all Processes ======
 +
 +In order to batch-kill multiple instances of the same process, the ''taskkill'' command can be used using the ''/IM'' parameter:
 +<code>
 +taskkill /IM firefox.exe /F
 +</code>
 +where:
 +  * ''/IM'' kills all processes,
 +  * ''/F'' forcibly terminates the process
 +
 +The command can be useful after a long session of various programs that tend to crash and do not remove themselves from the process list. Typically, this includes browsers like Chrome or Firefox that launch one instance of the browser per tab due to isolation and then end up crashing such that killing each and every single process from the task manager would be inconvenient.
 +
  

fuss/dos.txt · Last modified: 2023/12/16 03:33 by office

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.