Windows Tips

  • 从 CAB 文件中解出 DLL

有时候我们的设备上提示缺少某个Visual C++的DLL时,我们可以用这一方法获取安全可靠的DLL文件:

首先挂载ISO镜像,启动命令行,运行expand –d命令列出CAB中的内容,下面命令列出所有CAB中的文件并用grep过滤包含msvcp100d的文件。

F:\>expand -D *.cab | grep msvcp100d
 5394: cab21.cab: F_PDB_msvcp100d_i64
 5400: cab21.cab: F_REDIST_DLL_APPLOCAL_msvcp100d_i64
 5536: cab26.cab: F_PDB_msvcp100d_x64
 5541: cab26.cab: F_REDIST_DLL_APPLOCAL_msvcp100d_x64
 5979: cab44.cab: F_PDB_msvcp100d_x86
 5984: cab44.cab: F_REDIST_DLL_APPLOCAL_msvcp100d_x86

找到对应x64架构的文件,把cab26.cab解压后,重命名文件F_REDIST_DLL_APPLOCAL_msvcp100d_x64为msvcp100d.dll即可。

关于expand命令的用法如下:

F:\>expand /?
Microsoft (R) File Expansion Utility
Copyright (c) Microsoft Corporation. All rights reserved.

Expands one or more compressed files.

EXPAND [-R] Source Destination
EXPAND -R Source [Destination]
EXPAND -I Source [Destination]
EXPAND -D Source.cab [-F:Files]
EXPAND Source.cab -F:Files Destination

  -R            Rename expanded files.
  -I            Rename expanded files but ignore directory structure.
  -D            Display list of files in source.
  Source        Source file specification.  Wildcards may be used.
  -F:Files      Name of files to expand from a .CAB.
  Destination   Destination file | path specification.
                Destination may be a directory.
                If Source is multiple files and -r is not specified,
                Destination must be a directory.
  • 设置控制台雅黑字体

Microsoft YaHei Mono

打开字体文件并安装

修改注册表

运行Regedit,定位到计算机\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont,找到项936并设其值为*Microsoft YaHei Mono

设置字体

运行CMD->右键标题栏->属性->选择字体

  • 设置禁止或允许 U 盘
@echo off
 
set REGKEY=HKLM\SYSTEM\CurrentControlSet\Services\USBSTOR
 
if "%1"=="enable" (
    echo Enable the Mass Storage
    reg add %REGKEY% /v Start /t REG_DWORD /d 3 /f > NUL
    echo Done.
    exit
)
 
if "%1"=="disable" (
    echo Disable the Mass Storage
    reg delete %REGKEY% /v Start /f > NUL
    echo Done.
    exit
)
 
echo udisk - Enable / Disable the Mass Storage
echo usage: udisk [enable ^| disable]
  • 如何删除 EFI 文件系统分区
C:\Windows\system32>diskpart

DISKPART> select disk 0
Disk 0 is now the selected disk.

DISKPART> detail disk
TOSHIBA THNSNJ256GCSU
Disk ID: {...}
Type   : SATA
Status : Online
Path   : 0
Target : 0
LUN ID : 0
Location Path : PCIROOT(0)#PCI(1700)#ATA(C00T00L00)
Current Read-only State : No
Read-only  : No
Boot Disk  : No
Pagefile Disk  : No
Hibernation File Disk  : No
Crashdump Disk  : No
Clustered Disk  : No

Volume ### Ltr Label  Fs    Type      Size   Status  Info
---------- --- ------ ----- --------- ------ ------- ------
Volume 0       EFI    FAT32 Partition 200 MB Healthy Hidden

DISKPART> list partition
Partition ###  Type              Size     Offset
-------------  ----------------  -------  -------
Partition 1    System             200 MB    20 KB

DISKPART> select partition 1
Partition 1 is now the selected partition.

DISKPART> delete partition override
DiskPart successfully deleted the selected partition.

DISKPART> exit
Leaving DiskPart...
  • 解决 hypervisor is not running

在新机器上用Ghost恢复镜像后,启动Docker或者HyperV的时候提示

“Virtual machine 'MobyLinuxVM' could not be started because the hypervisor is not running.”

以Administrator启动CMD.EXE

C:\Windows\system32>coreinfo -v

Coreinfo v3.31 - Dump information on system CPU and memory topology
Copyright (C) 2008-2014 Mark Russinovich
Sysinternals - www.sysinternals.com

Note: Coreinfo must be executed on a system without a hypervisor running for
accurate results.

Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
Microcode signature: 00000096
HYPERVISOR      -       Hypervisor is present
VMX             *       Supports Intel hardware-assisted virtualization
EPT             *       Supports Intel extended page tables (SLAT)

C:\Windows\system32>bcdedit /set {current} hypervisorlaunchtype auto
The operation completed successfully.

C:\Windows\system32>bcdedit

Windows Boot Manager
--------------------
identifier              {bootmgr}
device                  partition=\Device\HarddiskVolume3
path                    \EFI\Microsoft\Boot\bootmgfw.efi
description             Windows Boot Manager
locale                  zh-CN
inherit                 {globalsettings}
default                 {current}
resumeobject            {db99b128-3d3d-11e8-9deb-b51706fc6ae8}
displayorder            {current}
toolsdisplayorder       {memdiag}
timeout                 30

Windows Boot Loader
-------------------
identifier              {current}
device                  partition=C:
path                    \Windows\system32\winload.efi
description             Windows 10
locale                  zh-CN
inherit                 {bootloadersettings}
recoverysequence        {d50d8342-9943-11e8-af7f-2016b9bffa30}
displaymessageoverride  Recovery
recoveryenabled         Yes
isolatedcontext         Yes
allowedinmemorysettings 0x15000075
osdevice                partition=C:
systemroot              \Windows
resumeobject            {db99b128-3d3d-11e8-9deb-b51706fc6ae8}
nx                      OptIn
bootmenupolicy          Standard
hypervisorlaunchtype    Auto

重启系统即可。

  • 如何修改 Windows 上的 MAC 地址
Open 'Control Panel '
-> Click 'View network status and tasks'
-> Click 'Change adapter settings'
-> Right click on a Connection (e.g. Local Ethernet)
-> Select 'Properties'
-> Click 'Configure...'
-> Choose tab 'Advanced'
-> Select 'Local Administered Address' in the 'Property' list box
-> Enter the MAC address to set in the 'Value' edit box on the right, e.g. 71AE889A2E21
  • 设置注册表的所有者和权限
set subinacl="C:\Program Files (x86)\Windows Resource Kits\Tools\subinacl.exe"
 
%subinacl% /keyreg HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\Root /setowner=system
%subinacl% /keyreg HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\Root /grant=system=f
%subinacl% /subkeyreg HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\Root /setowner=system
%subinacl% /subkeyreg HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\Root /grant=system=f

Download SubInACL.exe

  • 关闭休眠
$ powercfg -h off
  • 查看删除通知
$ fsutil behavior query disabledeletenotify
NTFS DisableDeleteNotify = 0  (Disabled)
ReFS DisableDeleteNotify = 0  (Disabled)
Disables (1) or enables (0) delete notifications. Delete notifications (also known as trim or unmap) is a feature that notifies the underlying storage device of clusters that have been freed due to a file delete operation. In addition:
For systems using ReFS v2, trim is disabled by default.
For systems using ReFS v1, trim is enabled by default.
For systems using NTFS, trim is enabled by default unless an administrator disables it.
If your hard disk drive or SAN reports that it doesn't support trim, then your hard disk drive and SANs don't get trim notifications.
Enabling or disabling doesn't require a restart.
Trim is effective when the next unmap command is issued.
Existing inflight IO are not impacted by the registry change.
Doesn't require any service restart when you enable or disable trim.

如果上面的命令返回 “DisableDeleteNotify = 0”, 那么 TRIM 已经启用. 否则可以通过下面的命令开启:

fsutil behavior set disabledeletenotify 0
  • Page File

如果内存足够大,那么可以关闭 Page File,或者设置为一个固定大小,另外如果有另外一块硬盘,可以把 Page File 设置到其他磁盘上。

  • Windows Server 远程桌面服务授权安装

安装服务器角色

Remote Desktop Services

Remote Desktop Licensing

Remote Desktop Session Host

Remote Desktop Virtualization Host

进入激活向导

安装完成后,启动Server Manager,选择Remote Desktop Service,Server列表中选择当前服务器,右键选择RD Licensing Manager。

RD Licensing Manager启动后,展开左侧All Servers,选中当前服务器,右键选择Activate Server,进入服务器激活向导。

复制对话框提供的产品ID,通过浏览器打开https://activate.microsoft.com 选择 Activate a license server,点击Next 输入产品ID、公司名(e.g. NA)和国家(e.g. Afghanistan),点击Next 返回License Server ID(e.g. RFP6V-JB7DG-BFYMT-T3BM4-3D944-XQ8FR-K8TF4) 用这个ID填入到激活向导。

再次打开激活网站,选择Install client access licenses

选择产品类型、授权数量和企业协议号码,协议号码可选:6565792, 4954438, 6879321或者5296992

remote-desktop-service!

确认选择

remote-desktop-service!

生成 Key Pack ID remote-desktop-service!

安装授权

remote-desktop-service!