Tag Archives: Windows 10

How to Install Ubuntu and Windows as a Dual Boot

Motivation:

You are want to install Ubuntu 18.04 and Windows 10 as dual boot for completing some machine learning tasks.

Prerequisites:

You need to have a 8Gb USB stick.

Solution:

Step 1: Go to BIOS, select the UEFI option in Boot List Option, disable the Enable Legacy option ROMS option, disable Secure Boot.

Step 2: Install Windows 10 and create a free partition for Ubuntu.

Step 3: Download the Ubuntu desktop 18.04 image.

Note: The Ubuntu server 18.04 image may NOT contain driver for your wireless adapter network card.

Download and use Rufus to create a bootable USB with Ubuntu.

Step 4: Install Ubuntu. Select Something else in Installation type screen. Select the free partition. Click the + sign.

Create a Swap partition. Set its size to be twice as your RAM size.

Create a Root partition. Set its size to be all the remaining free space to optimize your space.

 

 

 

 

How to Remove Caches and Temporary Files in Windows

Motivation:

You may want to remove caches to update an application status or fix some issues.
You may need to remove temporary files to get some more free disk space.

Solution:

Try clearing files and folders in the directories below.

  • %USERPROFILE%\AppData\Local\Temp
  • C:\Windows\Temp
  • C:\Users\All Users\Package Cache
  • C:\Windows\SoftwareDistribution\Download
  • C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files

Sometimes you may get permission error when deleting files or folders. If this is true then try the following command before deleting these files and folders.

takeown /f C:\Users\All Users\Package Cache /r /d y
icacls C:\Users\All Users\Package Cache /grant administrators:F /t

How to Hide Your IP Location using VPN in Windows 10

Motivation:

You have VPN credentials and want to hide your IP location for a specific purpose.

Solution:

  • Setup a VPN connection using your VPN credentials.
  • Type and click View network connections in Search box to open the Network Connections window.
  • Right-click the VPN connection and select Properties in the menu.
  • Select the Networking tab.
  • Click the Internet Protocol Version 4 (TCP/IPv4) row, then click the Properties button.
  • Click the Advanced… button.
  • Select Use default gateway on remote network option.

How to Run Docker on a Windows 10 Hyper-V Virtual Machine

Motivation:

You want to have an environment with Docker for development and testing  without interfering your stable machine.

Procedure:

1. Download this PowerShell script. The main interesting command in this script is the command below that enables Nested Virtualization for a virtual machine.

Set-VMProcessor -VMName $vmName -ExposeVirtualizationExtensions $true

2. Open PowerShell as Administrator and execute 2 commands below.

Set-ExecutionPolicy -ExecutionPolicy "Unrestricted"
.\Enable-NestedVm.ps1 "Windows 10 Dev"

"Windows 10 Dev" is the virtual machine name without quotes.

3. Install Docker. Restart the virtual machine.

4. Install any additional software if needed, restart the virtual machine again.

5. Open a Command Prompt and test Docker installation.

docker pull hello-world && docker run hello-world

Rerun the command if you get an issue in the first run.

How to Install a Fresh Windows 10 Booted from UEFI Secure Boot using a Bootable USB

Motivation:

Most of Windows machines are delivered with a limited Windows version and unnecessary preinstalled software.

You want to format the hard drive and install a fresh Windows that can be booted from UEFI secure boot to improve machine performance and stability.

Prerequisites:

You need to have a 8Gb USB stick and an ISO file of Windows 10, version 20h2.

Solution:

Step 1: Backup your machine and create an USB recovery by entering “Create a recovery drive” text to the search box on the task bar and follow the instructions.

Step 2: Create a bootable USB with Windows installation files.

Right click Windows logo, click Command Prompt (Admin).
Enter diskpart.exe, press Enter.
DISKPART> list disk
DISKPART> select disk 1 -- the USB disk should be selected, the number may be different in your machine.
DISKPART> clean
DISKPART> create partition primary size=1024
DISKPART> select partition 1
DISKPART> active
DISKPART> format quick fs=fat32
DISKPART> assign
DISKPART> create partition primary
DISKPART> select partition 2
DISKPART> format quick fs=ntfs
DISKPART> assign
DISKPART> exit
Double click on the ISO file of Windows 10, version 20h2 to create a virtual drive.
xcopy f:\sources\boot.wim d:\sources\ /s /e 

where
f: the virtual drive and 
d: the USB fat32 partition.
We copy only the f:\sources\boot.wim file to d:\sources\.
robocopy f:\ d:\ /IS /S /XD sources 

where 
f: the virtual drive and 
d: the USB fat32 partition.
We copy everything from f:\ to d:\ except the sources folder.
xcopy f:* e:\ /s /e 

where 
f: the virtual drive and 
e: the USB ntfs partition.

Step 3: Install Windows.

  1. Plug the USB to a machine.
  2. For a Dell laptop, power on the machine, press F12 until a one-time boot up menu appears. Select the option to boot the machine from the USB. (You may need to access BIOS to enable the option to boot the machine from an USB).
  3. For a Sony VAIO laptop, power off the machine, then press the Assist button to enter VAIOCare. Select the option to boot the machine from the USB. (You may need to access BIOS to enable the option to boot the machine from an USB).
  4. For a ThinkPad laptop, power on the machine, press F12 until a one-time boot up menu appears. Select the option to boot the machine from the USB. Alternatively go to Settings > Update & Security > Recovery, click the Restart now button under the Advanced setup section and follow the instructions to boot the machine from a USB.
  5. Follow the instructions to install Windows. Set Windows partition size to 512622Mb for DellPrecision if you want to have 500Gb C drive, or 262789Mb for DellXPS if you want to have a 255Gb C drive, or 819815Mb for ThinkPad if you want to have a 800Gb C drive.
  6. You can delete all the partitions, including MRP (Microsoft Reserved Partition – this is just a reserved partition for Windows later use if needed), ESP (EFI System Partition – this is where UEFI firmware files are stored to boot Windows), WINRETOOLS (Windows Recovery Environment (WinRE) Tools – this is where files for repairing or recovering Windows are stored), and PBR image (this is where original the manufacture Windows installation file  are stored) because you already created an USB recovery in the Step 1.

Step 4: Configure Windows for Developer’s needs.

  1. Change Computer Name, turn off System Restore, enable Remote Desktop.
  2. Add Wireless LAN Service feature for Windows Server 2019.
  3. For a Dell laptop, install Dell Wireless 1820A 1830 WiFi Driver. Set battery charge threshold value to 50% in BIOS.
  4. Change Time Zone.
  5. Turn on Network discovery and file sharing by clicking on Network icon on the left side of Explorer.
  6. Activate Windows.
  7. Disable Hibernation (powercfg.exe /h off), configure Power options (Hard disk >> Turn of hard disk after: 0, Wireless Adapter Settings >> Power Saving Mode: Maximum Performance, Sleep >> Sleep after: 0).
  8. Uninstall unnecessary applications.
  9. Use the manage-bde -status command to show BitLocker status (There is a space between bde and status). Use the manage-bde -off C: command to turn off BitLocker for the C drive.
  10. For a Dell laptop, install Dell Command Update and use it to install necessary drivers.
  11. For Windows Server 2019, install Chipset Device, Graphics, Audio, Ethernet, Bluetooth, Memory Card Reader, Dynamic Platform and Thermal Framework driver.
  12. For a ThinkPad laptop, install Lenovo Vantage. Set battery charge threshold value to 40% using Lenovo Vantage.
  13. Turn the following Windows features on: .NET 3.5, ASP.NET 4.8, Internet Information Services, Telnet Client.
  14. Install Total Commander, MS Office 2007 SP3, MS Project 2016, MS Visio 2016, MS SQL Server 2008 R2, Visual Studio 2015, Adobe Acrobat Pro DC v15.8, Adobe Photoshop CC 2015, TortoiseSVN 1.14.0
  15. Install Remote Desktop Connection Manager, PuTTY 0.7.3, WinSCP 5.17.
  16. Create a VPN connection. Configure the VPN connnection.
      Go to Control Panel >> Network and Sharing Center >> Change adapter settings >> Right click >> VPN Connection's Properties >> Select the Networking tab:
      - Disable Internet Protocol Version 6 (TCP/IPv6).
      - Select Internet Protocol Version 4 (TCP/IPv4) >> Properties >> Advanced... >> select the IP Settings tab: Uncheck the Use default gateway on remote network option.
    1. Install Python 3.6.8, TensorFlow, Keras
    2. Install Firefox, MPC-HC.1.7.13. (Go to View >> Options >> Player and turn off all options under the History section. Go to View >> Options >> Playback and disable the Auto-zoom feature.)
    3. Turn on Automatic Logon.
    4. Configure secure protocols using IIS Crypto GUI (Select Best Practices, disable TLS 1.0, TLS 1.1, MD5, SHA).
    5. Install Hyper-V, create an external Virtual Switch for Internet access, set Scheduler Type to Core.
    6. Apply Windows updates to the machine.

     

     

    How to Count the Number of Source Lines of Code, Find and Replace Content in Multiple Files

    Motivation:

    • You have a source code folder and want to know the number of source lines of code.
    • You want to find and replace a string with another string in multiple files.

    Procedure:

    1. Right click Start icon, click on Command Prompt (Admin) or Windows Powershell (Admin)
    2. Assume that the source code folder location is C:\Users\admin\Downloads\test, type below commands and press Enter
    cd C:\Users\admin\Downloads\test

    3. Assume that the source code file extension is .py, type below commands and press Enter

    type *.py | Measure-Object -line

    SLOC

    4. Assume that you want to find and replace “.flac” string with “.wav” string in all .cue files in the “E:\New Music\” directory, type below command, then press Enter.

    Get-ChildItem "E:\New Music\" *.cue -recurse | ForEach { (Get-Content -Path $_.FullName).Replace(".flac", ".wav") | Set-Content -Path $_.FullName }

    How to Detect Windows Original Install Date and Hot Fix Dates

    Motivation:

    You have an application that had been working well but it has encountered issues after you upgraded your Windows.

    You need to determine your Windows original install date to check when your application worked well and use the date to check which Windows version worked well with the application.

    You need to determine all of your hot fix dates to guess when your application may have been broken.

    Procedure:

    1. Right click Start icon, click on Command Prompt (Admin) or Windows Powershell (Admin)
    2. Type below command and press Enter to get the Windows original install date
    systeminfo | find /I "Install Date"

    Alternatively, you can use below command to get the Windows original install date

    ([WMI] "").ConvertToDateTime(((Get-WmiObject -class win32_operatingsystem).installdate))

    Type below command and press Enter to get the Windows hot fix dates

    Get-Hotfix | Sort-object InstalledOn -Descending

    • Displaying Windows OS information:
    systeminfo | findstr OS
    • Finding a KB:
    dism /online /get-packages | findstr KB4093119
    dism /online /get-packages | findstr KB3080079
    • Detecting Manufacturer name & Model number:
    wmic computersystem get model, name, manufacturer, systemtype

    How to Install Windows on your MacBook using Boot Camp

    Motivation:

    You have a MacBook and you want to use an application that only works on Windows.

    Procedure:

    1. Prerequisite:
    • Ensure that your macOS is up-to-date and does not have any issue.
    • If you want to reinstall macOS then you can hold down Command+R after powering your machine on.
    2. Installing Windows on your MacBook using Boot Camp

    On macOS:

    • Finder > Shift+Command+u > Boot Camp Assistant
    • Select 350Gb (or another appropriate size) for Windows. Use Windows 10 version 1909, April 2020 or Windows 10 version 1709, November 2017.
    • Remove unnecessary macOS applications (e.g. Numbers, Pages, Garage Band) if you want to use as much as possible storage for Windows.
    • Install Windows 10.
      – DO NOT USE Disk Management to create new partitions during Windows installation. Only use Disk Management to format an existing partition when installing Windows.
      – During the next boot into OS X, the OSXRESERVED partition is removed and put back into the Core Storage container of the OS X partition.

    On Windows:

    • Install Boot Camp drivers.
    • Boot Camp Control Panel… > TrackPad > Tap to Click.
    • Change Computer Name, disable System Protection, enable Remote Desktop, activate Windows.
    • Turn on Automatic Logon
      Command Prompt (Run as Administrator) >> netplwiz
    • Disable Hibernate
      Command Prompt (Run as Administrator) >> powercfg.exe /hibernate off
    • Power management > Change plan settings > Change advanced power settings
      >> Hard disk > Turn of hard disk after > Never
      >> Sleep > Sleep after > Never
    • Adjust System > Display > Brightness and color.
    • Uninstall unnecessary apps.
    • Use Disk Management to shrink the BOOTCAMP partition and create a new DATA partition. Use 150Gb (153600MB) as the amount of space to shrink.
    • Check and install Windows updates.
    • Copy portable apps.
    Developer’s tools:
    • Turn the following Windows features on: ASP.NET 3.5, 4.7, Internet Information Service, Telnet Client
    • Install Hyper-V, create an external Virtual Switch for Internet access
    • Install Total Commander, Remote Desktop Connection Manager
    • Install Firefox
    • Install MS SQL Server 2008 R2, MS Office 2007 SP3 (Display >> Scale and layout: 175%), MS Project 2016, MS Visio 2016, Visual Studio 2010, Visual Studio 2015, Adobe Acrobat Pro DC v15.8, Adobe Photoshop CC 2015, TortoiseSVN 1.11.1
    • Install Python 3.6.8, TensorFlow, Keras
    3. Removing Windows from your MacBook using Boot Camp

    On Windows:

    • Delete all Windows Data partitions, then Extend the Boot Camp volume (C:\) using Windows Disk Management.

    On macOS:

    • Finder > Shift+Command+u > Boot Camp Assistant > Continue > Restore
    • If you get any problem with Boot Camp Assistant then delete Windows Boot Camp partition using Disk Utility: Finder > Shift+Command+u > Disk Utility > Partition.
    • If you get a “Ghost” partition after deleting Windows Boot Camp partition using Disk Utility then please use the following procedure to remove it:

    Execute below command:

    diskutil list

    Find EFI IDENTIFIER (e.g. disk0s1).

    Execute 2 below commands:

    sudo mkdir /Volumes/efi
    sudo mount -t msdos /dev/disk0s1 /Volumes/efi

    Navigate to /Volumes/efi/EFI. Delete all directories (i.e. Microsoft and Boot) except the APPLE directory.

    Execute below command:

    diskutil unmount /Volumes/efi

    How to delete the Windows.old folder

    Motivation:

    After a major update Windows 10 leaves a folder named Windows.old in the system drive. You may remove it to save disk space and prevent potential harmful exploits.

    Solution

    Method 1:

    1. Click in Windows’ search field, type Cleanup, then click Disk Cleanup.
    2. Click the “Clean up system files” button.
    3. Wait a bit while Windows scans for files, then scroll down the list until you see “Previous Windows installation(s)“.
    4. Check the box next to the entry.
    5. Click OK.

    Method 2:

    1. Open a command prompt (cmd.exe) as Admin
    2. Execute 3 below commands:
    takeown /f C:\Windows.old /r /d y
    icacls C:\Windows.old /grant administrators:F /t
    rmdir C:\Windows.old /s /q

    takeown: takes ownership of a folder.

    icacls: grants permissions to a user against a folder

    rmdir: deletes a folder

    3. If some files still cannot be deleted then please restart your computer and re-excecute the above 3 commands.

    4. If some files still cannot be deleted after the restart then please execute 3 below commands:

    icacls C:\Windows.old /T /Q /C /RESET
    icacls C:\Windows.old /grant admin:F /t
    rmdir C:\Windows.old /s /q

    admin: your current logged in username.

    5. If some files still cannot be deleted then please click Cortona icon, type msconfig, click on System Configuration link, click Boot tab, select Safe boot check box,  select Minimal option, click OK, restart your computer and then execute the 3 commands in the 2nd step and the 3 commands in the 4th step.

    How to find a string in files

    Motivation:

    Find a string in all files in a directory without having to install an external program that may decrease system security.

    Method 1:

    1. Open a command prompt (cmd.exe)
    2. Go to the directory and
    3. Execute below command:
    find /i "search string" *.*

    /i: ignores the case of your search string.

    Examples:

    find /i "app files were copied" *.*
    find /i "were copied" *.log

    Method 2:

    1. Open a command prompt (cmd.exe)
    2. Go to the directory and
    3. Execute below command:
    findstr /s "search string" *.*

    /s: searches for each word in your search string.

    or execute below command:

    findstr /C:"search string" *.*

    /C: searches for exact match of your search string .

    Examples:

    findstr /s "Integrated Security=true" *.cs
    findstr /C:"app files were copied" *.log