Adding path permanently to windows using powershell doesn’t appear to work

Note: See the middle section for helper function Add-Path See the bottom section for why use of setx.exe should be avoided for updating the Path environment variable. The procedure in the linked blog post is effective in principle, but is missing a crucial piece of information / additional step: If you modify environment variables directly … Read more

Batch create folders based on part of file name and move files into that folder

@ECHO OFF SETLOCAL SET “sourcedir=c:\sourcedir” PUSHD %sourcedir% FOR /f “tokens=1*” %%a IN ( ‘dir /b /a-d “*_*_*-*-* *.*”‘ ) DO ( ECHO MD %%a ECHO MOVE “%%a %%b” .\%%a\ ) POPD GOTO :EOF This should accomplish the required task – or at least show the required instructions. If you are satisfied with the commands issued, … Read more

Unexpected page handling (also, VirtualLock = no op?)

Technically VirtualLock is a hint, and so the OS is allowed to ignore it. It’s backed by the NtLockVirtualMemory syscall which on Reactos/Wine is implemented as a no-op, however Windows does back the syscall with real work (MiLockVadRange). VirtualLock isn’t guarranteed to succeed. Calls to this function require the SE_LOCK_MEMORY_PRIVILEGE to work, and the addresses … Read more

Do high-integrity tokens *have* to have the Administrators group enabled?

No, the kernel does not require that the integrity level and elevation type of a token match up with the status of the Administrators group. This means that a process having a high integrity level, or TokenElevationTypeFull, does not necessarily have administrator access. In particular, note that using runas /trustlevel:0x20000 from an administrative command prompt … Read more

I need to match or replace an asterisk * in a batch environmental variable using only native Windows commands. Is this possible?

The easy answer is no. The problem that you’re encountering stems from the fact that the asterisk * is a special character when used with the SET search and replace method. It matches multiple characters in a limited, but still useful, way. You can learn about that here. The hard answer is Yes! I will … Read more