cmd

如何将 XML 的 XSD 定义转换为 C# 类

当我们将一些配置数据存储在 XML 文档中,或希望自定义某种 XML 格式的文档时,最好先去定义 XML 对应的 XSD 规范。定义 XSD 后,我们不仅可以在 VS 等 IDE 中对相应的 XML 文件的语法进行自动检查或属性匹配,同时也可以自动生成对应的实体类,简化 XML 的创建、修改以及读取。

打开 VS,在 XSD 文件上点击鼠标右键,点选 Open Command Prompt

Continue reading

Quick Tips: Open CMD here | 在当前位置打开命令行


We can right-click the mouse with Shift key to find the "Open command here" or "Open PowerShell window here" item to open the command line at current location.

But we often need to run the command line as an administrator, so you could register the following value to Windows Register to add a new item "Open command (as Admin) here" to Windows Explorer right-click menu.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
"Icon"="c:\\windows\\system32\\cmd.exe"
"MUIVerb"="Open command (as Admin) here"
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""

[HKEY_CLASSES_ROOT\folder\shell\runas]
"Icon"="c:\\windows\\system32\\cmd.exe"
"MUIVerb"="Open command (as Admin) here"
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\folder\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""

Open the Notepad and paste the text of above, save the file as OpenCMDHere.reg, and then double click this file, and click the "Yes" button in the message box.

The meaning of the above code is that we will create a new Windows shell item called "runas" at folder and the empty space in a folder, and set the Icon and propmt text.

HKEY_CLASSES_ROOT\Directory\shell, the context menu when you right-click on a folder
HKEY_CLASSES_ROOT\Directory\background, the context menu when you right-click on the "background" empty space while in a folder 

Then to define the running command of "runas" item:

cmd.exe /s /k pushd \"%V\"

That means to run the cmd.exe at the current working folder, the /k carries out the command specified by the following string so it executes the command pushd %V and since the only argument pushd accepts is a path it follows that %V a variable delivered by explorer that contains the path of the folder right clicked.

See more:
cmd command, https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490880(v%3dtechnet.10)
Pushd command, https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490978(v=technet.10)


我们可以在 Windows 的任意位置,通过 按下 Shift + 鼠标右键,来在当前位置启动 CMD 或 PowerShell。

但是,我们经常需要以管理员身份取运行 CMD,所以我们可以通过加载上述的值到注册表,来为右键菜单添加一个新的选项。将上述值保存到一个记事本中,并保存为 .reg 文件,然后双击运行,在后续提示中都选择 是,即可。