Skip to content

Instantly share code, notes, and snippets.

@kanchudeep
Last active May 27, 2024 13:34
Show Gist options
  • Save kanchudeep/11f631f0b595cbf15662e6df84394b20 to your computer and use it in GitHub Desktop.
Save kanchudeep/11f631f0b595cbf15662e6df84394b20 to your computer and use it in GitHub Desktop.
Add Linux Boot Option With bcdedit
1. bcdedit /create /d "Linux" /application BOOTSECTOR
2. bcdedit will return an ID for this entry (for example something like -
{de50478b-bb21-11e1-837e-001d72ceba3a}) that we will call {Linux-ID} below:
bcdedit /set {Linux-ID} device partition=C:
bcdedit /set {Linux-ID} path \boot-loader.bin
bcdedit /displayorder {FreeBSD_ID} /addlast
* Note: Get the BOOTSECTOR file from Linux using something like
dd if=/dev/sda3 of=/mnt/share/linux.bin bs=512 count=1
Add Non Default Open Option For Given File Type
1. Browse to: 'HKEY_CLASSES_ROOT\*\shell\'.
2. Create a new Key say 'your custom app'. Set default value say 'Open with
your custom app'.
3. Optionally set a String 'icon' with the icon e.g.
"C:\\Windows\\notepad.exe,0".
4. Add String 'AppliesTo' with the extension e.g. '.nfo'.
5. Add a sub Key 'command'. Set default string to the application. e.g.
'C:\\Windows\\notepad.exe \"%1\"'.
6. If you want to apply that command to more than one extension for
'AppliesTo' use: 'System.FileName:\"*.nfo\" OR System.FileName:\"*.log\"'.
REG file:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\your custom app]
@="Open with your custom app"
"icon"="C:\\Windows\\notepad.exe,0"
"AppliesTo"=".nfo"
[HKEY_CLASSES_ROOT\*\shell\your custom app\command]
@="C:\\Windows\\notepad.exe \"%1\""
Add Or Edit File Association
1. Right click HKEY_CLASSES_ROOT and pick New, Key. Name it according to your
desired file extension, e.g. .ext. If it exists already, you can skip this
step.
2. Set the default value of the key you just created to some unique name that
isn't used yet, e.g. MyFileType. Again, if it's set already, skip this step.
3. Create another new key using the same name you picked in the previous step. Skip this too, if the key exists already.
4. Set the default value of the new key to the name that should appear in
Windows Explorer and other programs as the file type.
5. Right click the new key and create a subkey DefaultIcon.
6. Set the new key's default value to C:\Some\Path\To\Your\Icon\Ressource.ico,0
(the 0 is the index of the icon to be used; if there's only one icon in the
resource, it has to be 0).
7. Create another new key next to DefaultIcon and call it shell.
8. Now, for each verb/action you'd like to associate, create a new sub key
with the desired name. Some verbs are preset and will automatically use
localized names, e.g. open, edit or print.
9. For each verb create a sub key command and set its default value to the
program to be run. Also make sure to include all parameters needed, adding
quotes if there are spaces inside, e.g. "C:\My Path\My Program.exe" "%1".
%1 will be replaced with the actual file name picked for this action.
10. Set the default value of the shell key to the name of the verb key you
wish to be default.
Blank Password For Shares (Windows XP?)
1. On the XP computer that is sharing the folder make sure you have both
the appropriate "Sharing/Permissions" and the "Security" settings set for the
folder.
2. To check, right click on folder and check those two tabs (also make sure
"Simple Folder Sharing" isn't turned on or those tabs won't be visible).
3. Go to the start menu and select the "Run" option, and then type
'gpedit.msc' and click "OK". Navigate to Computer Configuration / Windows
Settings / Security Settings / Local Policies / Security Options. Double click
on Accounts: Limit local account use of blank passwords to console login only.
Select the option next to Disabled and click "OK".
Close/Open Optical Drives
1. Save the following as cd-close.ps1:
$cd = Add-Type -memberDefinition @"
[DllImport("winmm.dll", CharSet = CharSet.Ansi)] public static extern int mciSendStringA(string lpstrCommand, string lpstrReturnString, int uReturnLength, IntPtr hwndCallback);
"@ -passthru -name mciSendString
$cd::mciSendStringA("set cdaudio door closed", $null, 0, 0);
2. Save the following as cd-open.psi:
$cd = Add-Type -memberDefinition @"
[DllImport("winmm.dll", CharSet = CharSet.Ansi)] public static extern int mciSendStringA(string lpstrCommand, string lpstrReturnString, int uReturnLength, IntPtr hwndCallback);
"@ -passthru -name mciSendString
$cd::mciSendStringA('set cdaudio door open', $null, 0, 0);
3. Allow running of unsigned PS scripts, from elevated command prompt:
powershell set-executionpolicy remotesigned
* To revert: powershell set-executionpolicy restricted
4. To run scripts:
powershell -windowstyle hidden -file cd-open.ps1
powershell -windowstyle hidden -file cd-close.ps1
* -windowstyle parameter is only available with PowerShell 2.0+
Configure Apache For Perl CGI
1. Add Perl ('perl/bin') to path.
2. Open the 'httpd.conf' Apache configuration file located in the
'apache/conf'.
3. Search the httpd.conf file for the line:
Options Indexes FollowSymLinks
Add ExecCGI to this line. The line should now look like the following:
Options Indexes FollowSymLinks ExecCGI
4. Next, search for the following:
#AddHandler cgi-script .cgi
Uncomment this line by removing the # in front of the line, and add a .pl to
the end of the line. The new line should look like this:
AddHandler cgi-script .cgi .pl
5. Restart Apache.
Disable Cortana in Windows 10
1. Start regedit with Administrative privileges.
2. Navigate to 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\
Windows Search'.
3. Create a new DWORD (32-bit) value with name 'AllowCortana' and set to '0'.
Disable Creation Of 'Thumbs.db' Files
1. Open 'Local Group Policy Editor':
gpedit.msc
2. Open 'User Configuration > Administrative Templates > Windows Components
> Windows Explorer' ('File Explorer' for Windows 8/10).
3. For 'Windows 7' open and enable 'Turn Off the caching of thumbnails in
hidden thumbs.db files'. For 'Windows 8/10' open and enable 'Turn off caching of
thumbnail pictures'.
Disable Some Windows Services
1. By default, there are many services that are automatically started when
Windows is loaded. While many of the services are needed, some can be
disabled to help secure the system. It is important to note that this section
is rather advanced, so you may not want to perform the following settings if
you are not comfortable with stopping services.
2. Before we begin, it is important to understand how to stop and disable
certain services. To do this, use the following steps:
a. Click the start button and then in the search box type 'services.msc'.
Press CTRL+Shift+ENTER to launch the 'Services' window. The CTRL+Shift
combination will launch the services window with an administrator ID, so
you may be prompted for the password. Enter the local administrator password
to continue.
b. Double-click the service in the list to open the service's properties
window.
c. From the 'Startup type' dropdown, select 'Disabled' from the list. This
will prevent the service from running at Windows startup.
d. Click the 'Stop' button to stop the service if it is currently running.
e. Click the 'OK' button to save your changes and close the window.
3. It is important to note that you should disable one service at a time.
Once you disable a service, see how your computer works when connected to the
Internet or across the network, and also by running your every day
applications. If something doesn't work right, re-enable the service. By using
the above steps, you should stop and disable the following services:
Media Center Extender Service
Net.Tcp Port Sharing Service
Remote Desktop Configuration
Remote Desktop Services
Remote Desktop Services UserMode Port Redirector
Remote Procedure Call (RPC) Locator
Routing and Remote Access
SeaPort
SSDP Discovery
TCP/IP Net BIOS Helper
UPnP Device Host
Windows Firewall * Disable only if you have another firewall installed
4. If you are not on a LAN and connected to other computers, such as you only
have one computer, then you can disable these services:
Function Discovery Provider Host
Function Discovery Resource Publication
HomeGroup Listener
HomeGroup Provider
Internet Connection Sharing (ICS)
Computer Browser
Server
5. In addition to disabling the above services, you can also set the
following to 'Manual' instead of 'Disabled':
Workstation
6. The above list shows the services that I currently have disabled on my
stand-alone desktop computer. I am currently having no issues with the above
services disabled.
Edit 'Open with...' List For A File Type
1. Browse to the following key:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ Explorer\FileExts\
2. Here you'll see a list of all the file extensions that are registered on
your computer.
3. Browse to the file extension you wish to edit, click the white triangle
beside it to see the subfolders, and select OpenWithList.
Enable Administrator Account During Installation
1. During the installation, after being prompted to configure the new user
account, you will be able to set the new account's password.
2. At that phase, press SHIFT and F10 keys together. A Command Prompt window
will appear.
3. In the Command Prompt window, type:
net user
* Note how the Administrator account is there, yet the new user account has
not been yet created.
4. To set the Administrator's account password:
net user administrator *
5. Then enter the required password and confirm it.
6. To enable the Administrator's account:
net user administrator /active:yes
7. Close the Command Prompt window and continue with the installation
process.
8. If you log off you will now see the Administrator's account as a valid
logon option.
Extract CHM File Contents
C:\Windows\hh.exe -decompile <Directory> <CHM File>
* Note: File/Directory name should be without spaces
Fix 'Installation Did Not Succeed' due to 'A certificate chain could not be
built to a trusted root authority.' on offline system
1. Download required certificate:
http://go.microsoft.com/fwlink/?linkid=747875&clcid=0x409
2. In Windows from command prompt run 'certmgr.msc'. Right click 'Trusted
Root Certification Authorities' and select 'All Tasks > Import'. Select the
downloaded certificate file.
3. Proceed with install.
Fix Stuck On 'Shutting Down...' Screen
1. Set 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\VerboseStatus'
as '1'.
2. Set 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\ClearPageFileAtShutdown'
as '0'.
3. Disable Paging. Restart Windows. Enable Paging.
Fix 'This copy of Windows is not genuine'
1. Uninstall update KB971033.
2. Execute: C:\Windows\SysWOW64\slmgr.vbs /rearm
Generating File Hash
CertUtil -hashfile [file] [Hash Algorithm]
* Hash Algorithms: MD2 MD4 MD5 SHA1 SHA256 SHA384 SHA512
Hide An Account
1. Execute:
regedit
2. In regedit go to 'HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\Winlogon'.
3. In the left panel, right click on 'Winlogon' and click 'New' and click
'Key'.
4. Type 'SpecialAccounts' and press 'Enter'.
5. In the left panel, right click on 'SpecialAccounts' and click 'New' and
click 'Key'.
6. Type 'UserList' and press 'Enter'.
7. In right panel of 'UserList', right click on a empty area and click 'New'
then click 'DWORD (32bit) Value'.
8. Type in the name of the user account that you want to hide and press
'Enter'.
9. In the right panel, right click on the user account name and click
'Modify'.
10. To hide the user account type '0' and click OK.
11. Whenever you want to use the account just unhide the it by typing '1'
instead of zero.
Install device drivers from .inf
pnputil -i -a X:\path\to\driver.inf
Install .MSU updates From Command Line
wusa.exe /norestart /quiet c:\path\to\update.msu
* Note:
1. /norestart: Prevent system restart (ignored if used with '/quiet').
2. /quiet: quiet mode without user interaction.
Install .NET Framework 3.5 in Windows 10 (Offline)
1. Insert Windows 10 DVD or USB or mount ISO. Not drive letter.
2. Run in command line:
dism /online /enable-feature /featurename:NetFX3 /All /Source:X:\sources\sxs /LimitAccess
Install Windows 10 MBR with single partition
1. Once install starts before selecting disk/partition to install to, press
'Shift+F10' and in command prompt:
diskpart
select disk 0
clean
create partition primary
format quick fs=ntfs label="Windows"
2. Select the created partition ('Windows') to install Windows to.
Install Windows 10 UEFI with minimum partitions (EFI and Windows partitions)
1. Once install starts before selecting disk/partition to install to, press
'Shift+F10' and in command prompt:
diskpart
select disk 0
clean
convert gpt
create partition efi size=100
format quick fs=fat32 label="System"
assign letter="S"
create partition primary
format quick fs=ntfs label="Windows"
assign letter="W"
2. Select the second created partition (W:/'Windows') to install Windows to.
Make Perl Scripts Act Like Normal Programs In Windows
* Note: Actions below require administrative privileges. For steps utilizing
the command prompt it must be launched via "Run as administrator" on Windows
Vista/7.
1. Associate *.pl files with perl. Run the following commands at a shell
prompt:
assoc .pl=PerlScript
ftype PerlScript=C:\bin\perl.exe "%1" %*
* Replace 'C:\Perl\bin\perl.exe' with the path to your Perl installation.
This enables you to run myscript.pl instead of perl myscript.pl.
2. Add .PL to your PATHEXT environment variable. This makes Windows consider
*.pl files to be executable when searching your PATH. It enables you to run
myscript instead of myscript.pl. Execute:
set PATHEXT=%PATHEXT%;.PL
3. To set it permanently (under Windows Vista or Windows 7)
setx PATHEXT %PATHEXT%;.PL
Prevent Windows 10 Auto Updates
1. Using Group Policy Editor (Professional version):
a. Open Group Policy Editor 'gpedit.msc'.
b. Disable 'Computer Configuration > Administrative Templates >
Windows Components > Windows Update > Configure Automatic Updates' or
set to '2 - Notify for download and auto install'.
2. Using Registry (non Professional version):
a. Start regedit with Administrative privileges.
b. Navigate to 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows' and
create key 'WindowsUpdate\AU' and then a DWORD (32-bit) Value named
'NoAutoUpdate' and set it from '0' to '1'. You can also set it to '2' to set
'2 - Notify for download and auto install' as in Group Policy Editor.
3. Using Services:
a. Run Services (Win+R > services.msc.
b. Open the service 'Windows Update' and change the 'Startup Type' to
'Disabled'.
4. Host file - add the lines:
0.0.0.0 windowsupdate.microsoft.com
0.0.0.0 *.windowsupdate.microsoft.com
0.0.0.0 *.update.microsoft.com
0.0.0.0 windowsupdate.com
0.0.0.0 *.windowsupdate.com
0.0.0.0 download.windowsupdate.com
0.0.0.0 download.microsoft.com
0.0.0.0 *.download.windowsupdate.com
0.0.0.0 wustat.windows.com
0.0.0.0 ntservicepack.microsoft.com
0.0.0.0 stats.microsoft.com
Require Username & Password For UAC
1. Run 'gpedit.msc'.
2. Open 'Computer Configuration > Administrative Templates > Windows
Components > Credential User Interface'.
3. Change the setting for "Enumerate administrator accounts on
elevation" to "disabled".
4. Run 'secpol.msc'.
5. Open 'Local Policies > Security Options'.
6. Disabled the setting "User Account Control: Allow UIAccess applications
to prompt for elevation without using the secure desktop".
* This hides accounts but allows UAC to access them through the Secure
Desktop.
Reset Windows 10 User Password
1. Backup and 'C:\Windows\System32\utilman.exe' with 'C:\Windows\System32\cmd.exe'.
2. On the login screen click 'Utility Manager' which will now run command
prompt.
3. Run following commands:
a. Add a new user with administrative privileges:
net user <username> <password> /add
net localgroup administrators <username> /add
b. Enable system Administrator account:
net user Administrator /active:yes
Resetting NTFS Files Security And Permission In Windows
1. Run "cmd" as Administrator.
* Note: In MS Windows 8 and above, press the Win+X keys, then choose "Command
Prompt (Admin)".
2. Go to the desired drive or folder.
3. To reset all the files permissions, type:
icacls * /T /Q /C /RESET
* Note:
a. The above is irreversible. Make sure you backup the permissions before
you proceed!
b. It is possible that "icacls" might fail. For that try to take ownership
of the files first. Just before step 3, execute:
takeown /R /F *
Stop WMP Making .jpg Files (Windows XP?)
1. Open Regedit then browse to:
HKEY_CURRENT_USER\Software\Microsoft\MediaPlayer\Preferences
2. Create two new DWORD entries
LargeAlbumArtSize
SmallAlbumArtSize
3. Give them the value of: 'ffffffff' and then reboot.
Turn Off Windows 10 Activation
1. Start regedit with Administrative privileges.
2. Navigate to 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\sppsvc'.
3. Set 'Start' as '4' (Hexadecimal).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment