Windows Specifications Used for Testing
- Edition: Windows 10 Pro
- Version: 22H2
- OS build: 19045.2965
| Note |
| The commands below were tested by running in Windows PowerShell as an Administrator. |
| Changes to the registry may require a restart before taking effect. |
Create Substituted Drive for All Users
Below is an example for creating a drive X: from the already existing folder C:\Games And Software.
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices" /v X: /t REG_SZ /d "\??\C:\Games And Software"
Removing Substituted Drive for All Users
Below is an example undoing the change made by the previous section.
reg delete "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices" /v X: /f
Enabling Recycle Bin for a Substituted Drive
Below is an example where the recycle bin is enabled for the substituted drive X:. This involves creating a new GUID (stored in the variable $guid). This GUID is then used to create the required key (stored in the variable $key).
$guid=$("{"+[guid]::NewGUID().ToString().ToUpper()+"}")
$key="HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\$guid"
reg add "$key" /v RelativePath /t REG_SZ /d X:\
reg add "$key" /v Name /t REG_SZ /d DriveX
reg add "$key" /v Category /t REG_DWORD /d 4
Disabling Recycle Bin for a Substituted Drive
Below is an example undoing the changes made by the previous section. The command below searches for the key.
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions /s /c /e /d /f DriveX
Below is example output from the above command.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{49476EF1-1FF2-4735-8D84-9453D4B90341}
Name REG_SZ DriveX
End of search: 1 match(es) found.
By using the key from the above output, the command below can be created. The command removes this key and all entries under this key.
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{49476EF1-1FF2-4735-8D84-9453D4B90341}" /f
References