#13 修改 cmd 字体

2021-02-14

Windows CMD 太挫,中文字体选择少,XP, Win7 下只有点阵字体 (fixedsys) 和新宋体,Win10 字体又多了几个,但效果页不太好。
不过 Win10 的话,可能是半年前吧,微软新出来了一个 Windows Terminal 的虚拟终端,就现代化多了。现在我在 Windows 下(偶尔)一般都是用的新版 Terminal + PowerShell,听方便。
但如果由于 OS 版本等问题,离不开 cmd 的话,有两个方法,一个是使用第三方终端模拟器,比如 cmder;再一个就是想办法定制一下 cmd 的字体。
我在这里记录一下之前使用的一个方案失效地址(确认有效,不过好久都没有用了)。

#12 Windows 特殊文件

2020-05-27
  • 虚拟内存相关
  • pagefile.sys:Windows 的交换(SWAP)文件。默认在 C 盘根目录,和内存一样大,可以在“高级系统设置”中更改其位置和大小。
  • hiberfil.sys:休眠模式系统状态转储文件。一般也会有几个 G。
  • swapfile.sys:Win10 引入,作用和 pagefile.sys 相同,但他的大小可以自动调整。
  • desktop.ini:文件夹配置文件(隐藏文件),用于自定义文件夹的外观和行为。
  • thumbs.db:缩略图缓存文件(隐藏文件),用于加快文件夹中图像文件的显示速度。
  • ntuser.dat:用户配置文件(隐藏文件),包含了用户的注册表设置和个人偏好。
  • boot.ini:启动配置文件,用于指定启动选项和操作系统位置。

#11 Git 链接文件

2020-03-22

Git 在团队协作的情况下容易遇到很多小问题,有一类是由于跨平台的系统差异导致的。有人习惯 Windows 下开发,有人习惯 Linux 下开发。

最常见的是这么四个问题:

  1. 文件权限问题
  2. 基本上我还没有遇到有需要给仓库中的文件设置权限的情况,但是由于权限的变更导致提交进来没有内容更改的文件就完全没有必要
  3. 所以非常必要设置 core.filemode false
  4. chmod 644 *.md
  5. 换行符问题
  6. Windows 新建的文件都是 \r\n 换行,Linux 则是 \n
  7. core.autocrlf true 可以在 checkout 的时候根据系统自动转换换行符
  8. 但是我觉得这个可能放到 hook 里面,在提交检查的时候一起做更加合适
  9. dos2unix *.md
  10. 软链接问题

  11. Linux 下的软链接切到 Windows 下之后,变成了一个普通文本,内容是链接的路径

  12. core.symlinks true 可以解决这个问题,这也是默认值,可是有些时候我们的环境中配置的就是 false
  13. 我的 Git for Windows 不知道为什么,system 配置就是设置成 false 了
  14. 有些情况下,项目配置似乎就默认是 false
  15. 如果已经成为现实了,软链是个文本,我们改配置,重新添加,然后 pull 到本地可以

core.symlinks
If false, symbolic links are checked out as small plain files that contain the link text. git-update-index and git-add will not change the recorded type to regular file. Useful on filesystems like FAT that do not support symbolic links.
The default is true, except git-clone or git-init will probe and set core.symlinks false if appropriate when the repository is created.

  1. 文件名大小写问题
  2. Linux 大小写敏感,比如 Apple.txt 和 apple.txt 可以在同一个目录,Windows 环境克隆下来,只能看到一个文件 apple.txt
  3. 没什么好的办法,应该也是在提交的时候作为风格检查
$ git config --list --global | grep sym
$ git config --list --system | grep sym
core.symlinks=false
$ git config --list --local | grep sym
core.symlinks=false

关于链接的另一个办法

CSDN 博客上看到 《windows上使用git仓库的问题(换行符、文件权限、软链接)》,里面提出下面这个思路。
虽然代码不够严谨,但是思路应该是没有问题的。以后遇到问题可以参考(还没有验证):

  1. 找出链接文件
  2. 创建 Windows 链接
  3. 操作索引区,忽略这个变更
import os

def rindex(lst, value):
    try:
        return lst.rindex(value)
    except ValueError:
        return -1

# find symbol link files or dirs
fp = os.popen("git ls-files -s | awk '/120000/{print $4}'")
links = fp.read().strip().split("\n")

# get symbol links' parent dir
link_dir = set()
for link in links:
    index = rindex(link, "/")
    if (index != -1):
        link_dir.add(link[:index])
    else:
        link_dir.add(".")

work_dir = os.getcwd()
# make link for every symbol link
for d in link_dir:
    os.chdir("/".join([work_dir,d]))
    fp = os.popen("ls -la")
    items = fp.read().strip().split("\n")
    for item in items:
        if "->" in item:
            tks = item.split("->")
            src = tks[0].strip().split(" ")[-1]
            dst = tks[1].strip().split("/")
            if (len(dst) > 1):
                dst = "\\\\".join(dst)
            else:
                dst = dst[0]
            print ("link " + src + " -> " + dst)
            os.popen("rm " + src)
            if (os.path.isfile(dst)):
                os.popen("cmd /c mklink /H " + src + " " + dst)
            else:
                os.popen("cmd /c mklink /j " + src + " " + dst)
            # make links unchanged
            os.popen("git update-index --assume-unchanged " + "/".join([os.getcwd(), src]))

参考资料与拓展阅读

#10 Windows 10 镜像下载

2020-03-19

https://msdn.itellyou.cn/

Windows 10 Enterprise LTSC 2019

# x64
Windows 10 Enterprise LTSC 2019 (x64) - DVD (Chinese-Simplified)
文件名:cn_windows_10_enterprise_ltsc_2019_x64_dvd_9c09ff24.iso
SHA1:24b59706d5eded392423936c82ba5a83596b50cc
文件大小:4.17GB
发布时间:2019-03-15
ed2k://|file|cn_windows_10_enterprise_ltsc_2019_x64_dvd_9c09ff24.iso|4478906368|E7C526499308841A4A6D116C857DB669|/

# x86 (32 位)
Windows 10 Enterprise LTSC 2019 (x86) - DVD (Chinese-Simplified)
文件名:cn_windows_10_enterprise_ltsc_2019_x86_dvd_1814dbab.iso
SHA1:ba2169edd94f123211cd4aaca68352f1ab6195d9
文件大小:2.98GB
发布时间:2019-03-15
ed2k://|file|cn_windows_10_enterprise_ltsc_2019_x86_dvd_1814dbab.iso|3196803072|2D39C54A2E99BAC308191C74A15B3237|/
Windows 10 Enterprise LTSC 2021 (x64) - DVD (Chinese-Simplified)
文件:SW_DVD9_WIN_ENT_LTSC_2021_64BIT_ChnSimp_MLF_X22-84402.ISO
大小:4.7GB
MD5:2579B3865C0591EAD3A2B45AF3CABEEE
SHA1:C19D7DAFBAFEB26C36E31D97C465E87C7A6E8A4C
SHA256:C117C5DDBC51F315C739F9321D4907FA50090BA7B48E7E9A2D173D49EF2F73A3
ed2k://|file|SW_DVD9_WIN_ENT_LTSC_2021_64BIT_ChnSimp_MLF_X22-84402.ISO|5044211712|1555B7DCA052B5958EE68DB58A42408D|/

Windows 11

ed2k://|file|zh-cn_windows_11_business_editions_version_22h2_updated_nov_2022_x64_dvd_3623b3e1.iso|5567041536|B83E64D03E93B418840E5B270E164005|/

#9 Windows 开机启动

2018-01-26

我想开机启动 TIM,但是 TIM 的设置没有用,重启之后这个选项又自己取消了,只好另外寻找方法。
发现这个方法就挺好用,只需把应用程序的快捷方式复制到一个目录。

这三个方法都可以用资源管理器打开这个目录:

  1. win + r 然后 shell:startup 回车
  2. explorer %appdata%\Microsoft\Windows\Start Menu\Programs\Startup
  3. explorer %userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

#8 Windows 命令大全

2018-01-15

Active Directory

  • ADmodcmd Active Directory Bulk Modify
  • CSVDE Import or Export Active Directory data
  • DSACLs Active Directory ACLs
  • DSAdd Add items to active directory (user group computer)
  • DSGet View items in active directory (user group computer)
  • DSQuery Search for items in active directory (user group computer)
  • DSMod Modify items in active directory (user group computer)
  • DSMove Move an Active directory Object
  • DSRM Remove items from Active Directory

Batch Files

  • CALL Call one batch program from another 内部命令
  • CHOICE Accept keyboard input to a batch file
  • CLIP Copy STDIN to the Windows clipboard
  • CLS Clear the screen 内部命令
  • CMD Start a new CMD shell
  • COLOR Change colors of the CMD window 内部命令
  • DOSKEY Edit command line, recall commands, and create macros
  • ECHO Display message on screen 内部命令
  • ENDLOCAL End localisation of environment changes in a batch file 内部命令
  • EVENTCREATE Add a message to the Windows event log
  • EXIT Quit the current script/routine and set an errorlevel 内部命令
  • FOR /F Loop command: against a set of files 内部命令
  • FOR /F Loop command: against the results of another command 内部命令
  • FOR Loop command: all options Files, Directory, List 内部命令
  • GOTO Direct a batch program to jump to a labelled line 内部命令
  • IF Conditionally perform a command 内部命令
  • IFMEMBER Is the current user a member of a Workgroup
  • LOGTIME Log the date and time in a file
  • MAPISEND Send email from the command line
  • MORE Display output, one screen at a time
  • PAUSE Suspend processing of a batch file and display a message 内部命令
  • PROMPT Change the command prompt 内部命令
  • REM Record comments (remarks) in a batch file 内部命令
  • RUN Start | RUN commands
  • RUNAS Execute a program under a different user account
  • SET Display, set, or remove session environment variables 内部命令
  • SETLOCAL Control the visibility of environment variables 内部命令
  • SETX Set environment variables
  • SORT Sort input
  • SHIFT Shift the position of batch file parameters 内部命令
  • SLEEP Wait for x seconds
  • START Start a program, command or batch file 内部命令
  • TIMEOUT Delay processing of a batch file
  • TITLE Set the window title for a CMD.EXE session 内部命令
  • WAITFOR Wait for or send a signal
  • WMIC WMI Commands
  • :: Comment / Remark 内部命令

Disk Management

  • BCDBOOT Create or repair a system partition
  • BCDEDIT Manage Boot Configuration Data
  • CONVERT Convert a FAT drive to NTFS
  • CHKDSK Check Disk - check and repair disk problems
  • CHKNTFS Check the NTFS file system
  • DEFRAG Defragment hard drive
  • DISKPART Disk Administration
  • DISKSHADOW Volume Shadow Copy Service
  • DriverQuery Display installed device drivers
  • FORMAT Format a disk
  • FREEDISK Check free disk space (in bytes)
  • LABEL Edit a disk label
  • MOUNTVOL Manage a volume mount point
  • NTBACKUP Backup folders to tape
  • SFC System File Checker
  • VOL Display a disk label 内部命令

Files and Folders

  • ASSOC Change file extension associations 内部命令
  • ASSOCIAT One step file association
  • ATTRIB Change file attributes
  • BITSADMIN Background Intelligent Transfer Service
  • CACLS Change file permissions
  • CD Change Directory - move to a specific Folder 内部命令
  • CIPHER Encrypt or Decrypt files/folders
  • COMP Compare the contents of two files or sets of files
  • COMPACT Compress files or folders on an NTFS partition
  • COMPRESS Compress individual files on an NTFS partition
  • COPY Copy one or more files to another location 内部命令
  • CSCcmd Client-side caching (Offline Files)
  • DEL Delete one or more files 内部命令
  • DELTREE Delete a folder and all subfolders
  • DIR Display a list of files and folders 内部命令
  • ERASE Delete one or more files 内部命令
  • EXPAND Uncompress files
  • EXTRACT Uncompress CAB files
  • FC Compare two files
  • FIND Search for a text string in a file
  • FINDSTR Search for strings in files
  • FORFILES Batch process multiple files
  • FSUTIL File and Volume utilities
  • FTP File Transfer Protocol
  • FTYPE File extension file type associations 内部命令
  • iCACLS Change file and folder permissions
  • MD Create new folders 内部命令
  • MOVE Move files from one folder to another 内部命令
  • MKLINK Create a symbolic link (linkd)
  • OPENFILES Query or display open files
  • POPD Return to a previous directory saved by PUSHD 内部命令
  • PsFile Show files opened remotely
  • PUSHD Save and then change the current directory 内部命令
  • RECOVER Recover a damaged file from a defective disk
  • REN Rename a file or files 内部命令
  • REPLACE Replace or update one file with another
  • RD Delete folder(s) 内部命令
  • RMTSHARE Share a folder or a printer
  • ROBOCOPY Robust File and Folder Copy
  • SHARE List or edit a file share or print share
  • SHORTCUT Create a windows shortcut (.LNK file)
  • SUBINACL Edit file and folder Permissions, Ownership and Domain
  • TAKEOWN Take ownership of a file
  • TOUCH Change file timestamps
  • TREE Graphical display of folder structure
  • TYPE Display the contents of a text file 内部命令
  • WHERE Locate and display files in a directory tree
  • WINDIFF Compare the contents of two files or sets of files
  • XCACLS Change file and folder permissions
  • XCOPY Copy files and folders

Group Policy/Windows Installer

  • DevCon Device Manager Command Line Utility
  • GPRESULT Display Resultant Set of Policy information
  • GPUPDATE Update Group Policy settings
  • MSIEXEC Microsoft Windows Installer
  • PsInfo List information about a system
  • PsShutdown Shutdown or reboot a computer
  • REGSVR32 Register or unregister a DLL
  • SHUTDOWN Shutdown the computer
  • SLMGR Software Licensing Management (Vista/2008)
  • WUAUCLT Windows Update

Networking

  • ARP Address Resolution Protocol
  • BROWSTAT Get domain, browser and PDC info
  • DNSSTAT DNS Statistics
  • GETMAC Display the Media Access Control (MAC) address
  • IPCONFIG Configure IP
  • NET Manage network resources
  • NETDOM Domain Manager
  • NETSH Configure Network Interfaces, Windows Firewall & Remote access
  • NBTSTAT Display networking statistics (NetBIOS over TCP/IP)
  • NETSTAT Display networking statistics (TCP/IP)
  • NMBIND Manage Hyper-V network bindings
  • NSLOOKUP Name server lookup
  • PATHPING Trace route plus network latency and packet loss
  • PsPing Measure network performance
  • PING Test a network connection
  • ROUTE Manipulate network routing tables
  • TRACERT Trace route to a remote host

Processes

  • PATH Display or set a search path for executable files 内部命令
  • PsExec Execute process remotely
  • PsKill Kill processes by name or process ID
  • PsList List detailed information about processes
  • PsGetSid Display the SID of a computer or a user
  • PsSuspend Suspend processes
  • SCHTASKS Schedule a command to run at a specific time
  • SYSMON Monitor and log system activity to the Windows event log
  • TASKLIST List running applications and services
  • TASKKILL End a running process
  • TSKILL End a running process
  • TLIST Task list with full path

Printing

  • MODE Configure a system device
  • PRINT Print a text file
  • PRINTBRM Print queue Backup/Recovery
  • RUNDLL32 Run a DLL command (add/remove print connections)

Recovery

  • BOOTREC Repair or replace a partition boot sector (WinRE).
  • BCDBOOT Create or repair a system partition.
  • BCDEDIT Manage Boot Configuration Data.
  • WPEUTIL Run commands during a Windows Preinstallation Environment (WinPE) session.

Registry

  • REG Registry: Read, Set, Export, Delete keys and values
  • REGEDIT Import or export registry settings
  • REGINI Change Registry Permissions

Remote Desktop

  • CHANGE Change Terminal Server Session properties
  • Query Process Display processes (TS/Remote Desktop)
  • Query Session Display all sessions (TS/Remote Desktop)
  • Query TermServer List all servers (TS/Remote Desktop)
  • Query User Display user sessions (TS/Remote Desktop)
  • MSTSC Terminal Server Connection (Remote Desktop Protocol)
  • RASDIAL Manage RAS connections
  • RASPHONE Manage RAS connections
  • Reset Session Delete a Remote Desktop Session
  • TSDISCON Disconnect a Remote Desktop Session
  • WINRM Windows Remote Management
  • WINRS Windows Remote Shell

Services

  • CASPOL Code Access Security Policy Tool.
  • PORTQRY Display the status of ports and services
  • PsService View and control services
  • SC Service Control

System Information

  • CHANGEPK Upgrade device Edition/Product Key
  • DATE Display or set the date 内部命令
  • HELP Online Help
  • LOGMAN Manage Performance Monitor logs
  • MBSAcli Baseline Security Analyzer
  • MSINFO32 System Information
  • NOW Display the current Date and Time
  • NTRIGHTS Edit user account rights
  • PsLogList Event log records
  • SFC System File Checker
  • SXSTRACE Diagnose side-by-side problems.
  • SYSMON Monitor and log system activity to the Windows event log
  • SYSTEMINFO List system configuration
  • TIME Display or set the system time 内部命令
  • TypePerf Write performance data to a log file
  • VER Display version information 内部命令
  • VERIFY Verify that files have been saved 内部命令
  • WHOAMI Output the current UserName and domain

User Administration

  • ADDUSERS Add or list users to/from a CSV file
  • CERTREQ Request certificate from a certification authority
  • CleanMgr Automated cleanup of Temp files, recycle bin
  • CON2PRT Connect or disconnect a Printer
  • CMDKEY Manage stored usernames/passwords
  • DELPROF Delete user profiles
  • DIRUSE Display disk usage
  • LOGOFF Log a user off
  • MOVEUSER Move a user from one domain to another
  • MSG Send a message
  • PERMS Show permissions for a user
  • POWERCFG Configure power settings
  • PsLoggedOn Who's logged on (locally or via resource sharing)
  • PsPasswd Change account password
  • SUBST Associate a path with a drive letter

Commands marked • are Internal commands only available within the CMD shell.
All other commands (not marked with •) are external commands.
External commands may be used under the CMD shell, PowerShell, or directly from START-RUN.

参考资料与拓展阅读

#7 Windows 系统变量

2016-10-01
@echo off

echo Current Directory: %cd%
echo %date% , %time%

echo.
echo ================================================================================
echo.

echo %systemroot%
echo %windir%

echo.
echo ================================================================================
echo.

echo cmd.exe Path: %cmdcmdline%
: C:\windows\System32\cmd.exe
echo cmd.exe Extension Version: %cmdextversion%
echo %comspec%
: same with cmdcmdline

echo.
echo ================================================================================
echo.

echo %path%
echo %pathext%
: .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

echo.
echo ================================================================================
echo.

echo %os%
: Windows_NT

echo %number_of_processors%
echo %processor_architecture%
: AMD64
echo %processor_identifier%
echo %processor_level%
echo %processor_revision%

echo %random%
echo %prompt%

echo.
echo ================================================================================
echo.

echo %logonserver%
echo %userdomain% (hostname)
echo %computername%

echo.
echo ================================================================================
echo.

echo %username%
echo %userprofile%

echo %homedrive%
echo %homepath%

echo %temp%
echo %tmp%
echo %appdata%