Windows 上有用的命令行命令

dan*_*die 281 windows command-line-interface windows-command-prompt

此 Wiki 的目的是促进使用命令打开常用应用程序,而无需多次单击鼠标 - 从而节省监控和排除 Windows 机器故障的时间。

回答条目需要指定

  • 应用名称
  • 命令
  • 截图(可选)

命令的快捷方式

spl*_*tne 121

一个鲜为人知的是

getmac
Run Code Online (Sandbox Code Playgroud)

它显示您的网络适配器的MAC 地址

从 Windows 命令行窗口运行 getmac 的屏幕截图。

  • ipconfig /all 也以不太直接的方式为您提供此信息。 (5认同)
  • 谢谢你!没有更多的 ipconfig /all 和滚动!“快乐的舞蹈!” (2认同)

Tor*_*oro 65

在命令提示符中键入:

C:\> start .
Run Code Online (Sandbox Code Playgroud)

它会在 Windows 资源管理器中打开当前目录。

  • 你也可以做“资源管理器”。 (5认同)
  • 请注意,如果文件名中包含空格,则 start 可能会有点有趣。如果引用了 start 的第一个参数,它会将其解释为更改窗口标题的请求。所以不是运行: start "My File.txt" 你必须输入: start "" "My File.txt" 这让我发疯,直到有人向我解释! (5认同)
  • 多么整洁。它就像“ii”一样工作。在 PowerShell 中。 (2认同)
  • start 实际上适用于您可以双击的任何文件类型(word 文档、xls 文件等)以及驱动器映射(不仅仅是当前工作目录)。 (2认同)

dan*_*die 51

远程桌面连接

mstsc.exe
Run Code Online (Sandbox Code Playgroud)

打开:

mstsc.exe 使用的一些图像演示。

  • 不要忘记在两个显示器上创建真正大的会话的 /span 选项。 (17认同)
  • 使用 /v: 开关效果更好。只需 Win+R,然后“mstsc /v:computer.fabrikam.com” (16认同)
  • 这些天重命名为 /admin 开关,并且在 2008+ 中的行为完全不同 (9认同)
  • 在此期间,我也经常使用 /w: 和 /h: 手动设置宽度和高度。出于某种原因,我特别喜欢在 800x800 中运行 IIS 管理器。 (7认同)
  • 在 Vista SP1 及更高版本中重命名为 /console,因为他们一开始就不应该更改它。:) (6认同)
  • 还有 /console 开关 (4认同)

K. *_*ley 45

我经常使用的列表:

  • nbtstat - 列出 NetBIOS 统计信息和信息
  • netstat - 列出 TCP/IP 统计信息和信息
  • ipconfig - 列出系统的 TCP/IP 配置
  • netsh - 系统的网络配置
  • sc - 管理服务
  • net - 用于管理用户和组、共享、连接等的大量命令。
  • ping - 确保系统在网络上启动
  • tracert - 跟踪两台主机之间的跃点。查看两者之间是否有中断以及它的位置很有用。
  • nslookup - 查询 DNS 信息
  • dcdiag - 检查域控制器的健康状况
  • setspn - 检查 Kerberos 配置的 SPN


小智 44

服务控制面板:

services.msc
Run Code Online (Sandbox Code Playgroud)


Fro*_*rud 41

shutdown.exe
Run Code Online (Sandbox Code Playgroud)

允许您关闭或重新启动机器。您甚至可以使用以下命令重新启动远程机器

shutdown -m \\server -t 0 -r
Run Code Online (Sandbox Code Playgroud)

它甚至带有图形用户界面

shutdown -i
Run Code Online (Sandbox Code Playgroud)

你可以中止关机

shutdown -a
Run Code Online (Sandbox Code Playgroud)


tho*_*ter 37

Robocopy真的很有用。它镜像目录。

它非常适合备份、恢复和传输大量文件。它只传输已更改的文件,并且可以从中断的地方恢复。

它是 Windows Vista 和更高版本的标准配置,但 Windows XP 用户可以将它作为 Windows Server 2003 Resource Kit(免费)或更高版本的一部分获得。


Nic*_*aux 34

(本身并不是一个真正的命令,而是一种到达那里的方法。)

对于那些发现自己经常去开始>运行>“cmd”的人,你可以减少一些步骤。

假设您想获取您的 IP 地址。你通常会去开始>运行>“cmd”[输入]然后......

ipconfig [enter]
Run Code Online (Sandbox Code Playgroud)

现在,去...

开始>运行>“cmd /k ipconfig”

这将运行 cmd 和命令“ipconfig”,并保持窗口打开。因此,如果我想快速获取我的 MAC 地址(物理地址),我会这样做:

 cmd /k ipconfig /all
Run Code Online (Sandbox Code Playgroud)

...全部来自运行菜单中的一行。


所有礼貌波士顿马克

  • 这是一个更好的方法:转到开始 > 所有程序 > 附件 > 命令提示符,然后右键单击。选择属性。单击“快捷方式”选项卡。将光标放在“快捷键”字段中。按 [ctrl]-[alt]-t,它应该显示“Ctrl+Alt+T”。单击确定。现在您可以通过按 ctrl-alt-t 随时随地启动 cmd.exe。 (10认同)
  • 此外,使用 windowskey+r 可以让您直接进入“运行...”窗口。 (5认同)
  • 是的,/k 标志绝对是这里最好的提示之一。 (3认同)

Jos*_*ern 28

被遗忘的艺术:DOS 字符串操作!

set mydate=%date:~10,4%_%date:~4,2%_%date:~7,2%
echo %mydate%
Run Code Online (Sandbox Code Playgroud)

输出将为YYYY_MM_DD.

将其复制并粘贴到 .bat 文件中,您会大吃一惊!这对于创建备份或任何时间/日期系列的目录和文件特别有用。

一个例子:

@echo off
:: Yes, this looks bad, but it works, it sets the file veriable mydate to YYYY_MM_DD.
set mydate=%date:~10,4%_%date:~4,2%_%date:~7,2%

echo Backing up DC1:
:: start a new backup session, the /M switch is for the type of bakcup being performed, type ntbackup /? for more info
start /wait ntbackup backup \\DC1\c$ /j "DC1 Backup" /f "C:\BAK\DC1\DC1_%mydate%.bkf" /M incremental
echo DC1 is Done

echo Backing up EXCH:
start /wait ntbackup backup \\EXCH\c$ /j "EXCH Backup" /f "C:\BAK\EXCH\EXCH_%mydate%.bkf" /M incremental
echo EXCH is Done

echo Backing up FS1:
start /wait ntbackup backup \\FS1\c$ /j "FS1 Backup" /f "C:\BAK\FS1\FS1_%mydate%.bkf" /M incremental
echo FS1 is Done

echo Backup was completed %date% %time%
pause
Run Code Online (Sandbox Code Playgroud)

  • 这是非常危险的,因为系统区域设置显示格式会更改日期返回的字符串,因此如果它发生变化,任何基于字符位置的脚本都会变成不可预测的混乱。至少在欧洲,这很容易被错误或故意发生 - 我已经安排批处理脚本做可怕的事情(或什么都不做)正是因为这个^^ (5认同)

Fro*_*rud 26

tasklist.exe
Run Code Online (Sandbox Code Playgroud)

将列出本地或远程机器上的进程。

tasklist.exe /S server
Run Code Online (Sandbox Code Playgroud)

它可以显示 scvhost.exe 进程托管的服务

tasklist /SVC
Run Code Online (Sandbox Code Playgroud)

你也可以做一些过滤。这将显示使用了超过 15 分钟 CPU 时间的远程机器上的进程

tasklist /S server /FI "CPUTIME gt 00:15:00"
Run Code Online (Sandbox Code Playgroud)


Iga*_*nik 25

control userpasswords2

打开经典的用户帐户对话框:

在此处输入图片说明


小智 24

我发现我findstr经常在日志、错误文件等中查找内容。

一个简单的例子:在日志文件中,ex0905.log我们找到其中包含的所有行2009-05-05

findstr "2009-05-05" ex0905.log
Run Code Online (Sandbox Code Playgroud)


dan*_*die 22

程序和功能(以前称为“添加或删除程序”)

appwiz.cpl
Run Code Online (Sandbox Code Playgroud)

打开

替代文字


Ivo*_*ser 21

有时我不得不担心终端服务器连接到服务器的空闲会话太少。

quser 在终端服务器上显示有关用户会话的信息。

quser /SERVER:myserver
Run Code Online (Sandbox Code Playgroud)

输出

C:\Documents and Settings\sysmanager01>quser /SERVER:serverx
USERNAME                    SESSIONNAME        ID  STATE   IDLE TIME  LOGON TIME
usr_hot1                                        1  Disc        none   30.04.2009 17:59
usr_hot                                         2  Disc        none   30.04.2009 18:01
appsuperuser                rdp-tcp#6           3  Conn            .  01.01.1601 02:00
Run Code Online (Sandbox Code Playgroud)

有时甚至有可能找到纯粹的工作狂,例如appsuperuser:-)

quser可执行文件从任何 32 位服务器粘贴到我的本地 System32 文件夹时会更容易。

  • 尝试改用 qwinsta,默认情况下它也包含在 XP 等客户端中...... rwinsta 可以破坏会话 (6认同)

小智 17

我用

qwinsta
Run Code Online (Sandbox Code Playgroud)

查看断开连接的远程桌面会话和

logoff
Run Code Online (Sandbox Code Playgroud)

结束他们。

它适用于Windows 2000Windows XPWindows VistaWindows Server 2003Windows Server 2008(从未尝试过)。


dan*_*die 16

计算机管理

compmgmt.msc
Run Code Online (Sandbox Code Playgroud)

打开
在此处输入图片说明


phu*_*ion 16

systeminfo
Run Code Online (Sandbox Code Playgroud)

显示有关手头系统的大量信息。以下是它在 Vista 上的输出:

  • 主机名
  • 操作系统名称
  • 操作系统版本
  • 操作系统制造商
  • 操作系统配置
  • 操作系统构建类型
  • 注册拥有人
  • 注册机构
  • 产品编号
  • 原始安装日期
  • 系统启动时间
  • 系统制造商
  • 系统模型
  • 系统类型
  • 处理器
  • BIOS 版本
  • 视窗目录
  • 系统目录
  • 启动装置
  • 系统区域
  • 输入语言环境
  • 时区
  • 总物理内存
  • 可用物理内存
  • 页面文件
  • 最大尺寸
  • 页面文件
  • 可用的
  • 页面文件
  • 正在使用
  • 页面文件位置
  • 领域
  • 登录服务器
  • 修补程序
  • 网卡


小智 15

非常有用的一个我最近才发现的:

winver.exe
Run Code Online (Sandbox Code Playgroud)

为您提供一个对话框,其中包含机器正在运行的 Windows 版本,包括 Service Pack 级别和内部版本号。

  • 请注意,我使用热键 Win+Pause 来快速查看盒子上的大部分信息。 (9认同)

小智 14

仍然没有提到 WMIC.exe :)

从远程机器、本地机器......多台机器上找到你想要的任何东西。

精心填写的 HTML 页面,其中包含与操作系统相关的所有数据

WMIC OS get /all /format:htable
Run Code Online (Sandbox Code Playgroud)

查看所有可用选项

ALIAS                    - Access to the aliases available on the local system
BASEBOARD                - Base board (also known as a motherboard or system board) management.
BIOS                     - Basic input/output services (BIOS) management.
BOOTCONFIG               - Boot configuration management.
CDROM                    - CD-ROM management.
COMPUTERSYSTEM           - Computer system management.
CPU                      - CPU management.
CSPRODUCT                - Computer system product information from SMBIOS.
DATAFILE                 - DataFile Management.
DCOMAPP                  - DCOM Application management.
DESKTOP                  - User's Desktop management.
DESKTOPMONITOR           - Desktop Monitor management.
DEVICEMEMORYADDRESS      - Device memory addresses management.
DISKDRIVE                - Physical disk drive management.
DISKQUOTA                - Disk space usage for NTFS volumes.
DMACHANNEL               - Direct memory access (DMA) channel management.
ENVIRONMENT              - System environment settings management.
FSDIR                    - Filesystem directory entry management.
GROUP                    - Group account management.
IDECONTROLLER            - IDE Controller management.
IRQ                      - Interrupt request line (IRQ) management.
JOB                      - Provides  access to the jobs scheduled using the schedule service.
LOADORDER                - Management of system services that define execution dependencies.
LOGICALDISK              - Local storage device management.
LOGON                    - LOGON Sessions.
MEMCACHE                 - Cache memory management.
MEMLOGICAL               - System memory management (configuration layout and availability of memory).
MEMPHYSICAL              - Computer system's physical memory management.
NETCLIENT                - Network Client management.
NETLOGIN                 - Network login information (of a particular user) management.
NETPROTOCOL              - Protocols (and their network characteristics) management.
NETUSE                   - Active network connection management.
NIC                      - Network Interface Controller (NIC) management.
NICCONFIG                - Network adapter management.
NTDOMAIN                 - NT Domain management.
NTEVENT                  - Entries in the NT Event Log.
NTEVENTLOG               - NT eventlog file management.
ONBOARDDEVICE            - Management of common adapter devices built into the motherboard (system board).
OS                       - Installed Operating System/s management.
PAGEFILE                 - Virtual memory file swapping management.
PAGEFILESET              - Page file settings management.
PARTITION                - Management of partitioned areas of a physical disk.
PORT                     - I/O port management.
PORTCONNECTOR            - Physical connection ports management.
PRINTER                  - Printer device management.
PRINTERCONFIG            - Printer device configuration management.
PRINTJOB                 - Print job management.
PROCESS                  - Process management.
PRODUCT                  - Installation package task management.
QFE                      - Quick Fix Engineering.
QUOTASETTING             - Setting information for disk quotas on a volume.
RECOVEROS                - Information that will be gathered from memory when the operating system fails.
REGISTRY                 - Computer system registry management.
SCSICONTROLLER           - SCSI Controller management.
SERVER                   - Server information management.
SERVICE                  - Service application management.
SHARE                    - Shared resource management.
SOFTWAREELEMENT          - Management of the  elements of a software product installed on a system.
SOFTWAREFEATURE          - Management of software product subsets of SoftwareElement.
SOUNDDEV                 - Sound Device management.
STARTUP                  - Management of commands that run automatically when users log onto the computer system.
SYSACCOUNT               - System account management.
SYSDRIVER                - Management of the system driver for a base service.
SYSTEMENCLOSURE          - Physical system enclosure management.
SYSTEMSLOT               - Management of physical connection points including ports,  slots and peripherals, and
TAPEDRIVE                - Tape drive management.
TEMPERATURE              - Data management of a temperature sensor (electronic thermometer).
TIMEZONE                 - Time zone data management.
UPS                      - Uninterruptible power supply (UPS) management.
USERACCOUNT              - User account management.
VOLTAGE                  - Voltage sensor (electronic voltmeter) data management.
VOLUMEQUOTASETTING       - Associates the disk quota setting with a specific disk volume.
WMISET                   - WMI service operational parameters management.
Run Code Online (Sandbox Code Playgroud)

还有很多很多。


Osk*_*orn 13

链接命令,尤其是net stopstart重新启动任何服务:

net stop w3svc && net start w3svc
Run Code Online (Sandbox Code Playgroud)

(这是一个愚蠢的例子,iisreset会这样做,但无论如何;)

  • 只是指出这实际上是条件执行,与单个“&”不同。http://www.ss64.com/nt/syntax-conditional.html (5认同)
  • 但是,这将确保保存元数据库配置更改。IISRESET 没有。 (3认同)

小智 13

color 02
Run Code Online (Sandbox Code Playgroud)

朋友们,这是您永远需要的唯一命令。其余的都是不必要的。

  • 糟糕,我不小心输入了颜色 23... (2认同)

Ric*_*ard 12

explorer .
Run Code Online (Sandbox Code Playgroud)

选择当前文件夹打开资源管理器。

explorer /e, .
Run Code Online (Sandbox Code Playgroud)

打开资源管理器,带有文件夹树,选择当前文件夹。


Ste*_*ong 12

要更改您打开的 CMD 窗口的标题,只需使用:

title [your new title]

我在工作中打开了很多 CMD 窗口和其他程序。此命令与 Taskbar Shuffle(允许您将任务栏项目拖到新订单中)相结合,使我免于发疯。


小智 11

Windows 7 运行命令

我发现最好知道在哪里可以找到它们,直到我经常使用它们以真正记住它们。


小智 10

至少在 Windows XP 上(我没有在 Windows Vista 和 Windows 7 上尝试过):

appwiz.cpl @,2
Run Code Online (Sandbox Code Playgroud)

它会将您直接带到“添加/删除 Windows 组件”窗格。

以自动化方式添加或删除组件的另一种方法是使用

sysocmgr.exe
Run Code Online (Sandbox Code Playgroud)

在无人参与模式下使用 .inf 文件列出您要安装的组件。例如,

[NetOptionalComponents] 
SNMP = 1 

[SNMP] 
Contact_Name = IT Dept. 
Location = Office
Service = Physical, Applications, End-to-End 
Community_Name = Mormon 
Traps = server1, server2 
Send_Authentication = Yes 
Accept_CommunityName = Public:Read_Only 
Any_Host = No 
Limit_Host = server1, server2
Run Code Online (Sandbox Code Playgroud)

(归功于 .inf 文件的 systemadministrator.com。)

这是一个笨重的工具(嘿,它是 MS),但它对于在安装后整理您的组件非常宝贵。


Gul*_*zar 10

重新启动 IIS

iisreset
Run Code Online (Sandbox Code Playgroud)

  • 这也可用于在远程服务器上重新启动 IIS: iisreset remoteservername (3认同)
  • 我不再使用 iisreset 了。它可能无法保存元数据库配置问题。我改用 net stop iisadmin /y && net start w3svc 。原因如下:http://support.microsoft.com/default.aspx/kb/286196 (3认同)

ato*_*255 10

我还没有在列表中看到 taskkill。

TASKKILL [/S system [/U username [/P [password]]]] { [/FI filter] [/PID processid | /IM 图像名称] } [/F] [/T]

参数列表:/S system 指定要连接的远程系统。

/U    [domain\]user    Specifies the user context under which
                       the command should execute.

/P    [password]       Specifies the password for the given
                       user context. Prompts for input if omitted.

/F                     Specifies to forcefully terminate
                       process(es).

/FI   filter           Displays a set of tasks that match a
                       given criteria specified by the filter.

/PID  process id       Specifies the PID of the process that
                       has to be terminated.

/IM   image name       Specifies the image name of the process
                       that has to be terminated. Wildcard '*'
                       can be used to specify all image names.

/T                     Tree kill: terminates the specified process
                       and any child processes which were started by
Run Code Online (Sandbox Code Playgroud)

它。

与任务列表配合使用效果很好


cop*_*152 10

您可以在 Windows 命令行中按 F7 以查看可以使用键盘选择的命令历史记录。

另外...我喜欢这个 - 您只需将文件拖到命令行中即可复制文件路径。


dan*_*die 9

装置经理

devmgmt.msc
Run Code Online (Sandbox Code Playgroud)

打开

在此处输入图片说明

  • 如果您在启动设备管理器之前将环境变量 devmgr_show_nonpresent_devices 设置为 1,那么当您显示隐藏设备时,它也会显示所有完全不活动的设备(例如已被删除)。 (7认同)

dan*_*die 8

事件查看器

eventvwr.msc
Run Code Online (Sandbox Code Playgroud)

打开 在此处输入图片说明


dan*_*die 8

网络连接 (Windows Vista/Windows XP)

命令

ncpa.cpl
Run Code Online (Sandbox Code Playgroud)

打开

替代文字


Ric*_*den 8

dsquery * 和 dsmod

将您的dsquery结果dsmod传送到Active Directory 中并对Active Directory进行大量更改。

Description:  Finds any objects in the directory according to criteria.

Syntax:     dsquery * [{<StartNode> | forestroot | domainroot}]
            [-scope {subtree | onelevel | base}] [-filter <LDAPFilter>]
            [-attr {<AttrList> | *}] [-attrsonly] [-l]
            [{-s <Server> | -d <Domain>}] [-u <UserName>]
            [-p {<Password> | *}] [-q] [-r] [-gc]
            [{-uc | -uco | -uci}]

Parameters:
Value                       Description
{<StartNode> | forestroot | domainroot}
                            The node where the search will start:
                            forest root, domain root, or a node
                            whose DN is <StartNode>.
                            Can be "forestroot", "domainroot" or an object
                            DN.
                            If "forestroot" is specified, the search is done
                            via the global catalog. Default: domainroot.
-scope {subtree | onelevel | base}
                            Specifies the scope of the search:
                            subtree rooted at start node (subtree);
                            immediate children of start node only (onelevel);
                            the base object represented by start node (base).
                            Note that subtree and domain scope
                            are essentially the same for any start node
                            unless the start node represents a domain root.
                            If forestroot is specified as <StartNode>,
                            subtree is the only valid scope.
                            Default: subtree.
-filter <LDAPFilter>        Specifies that the search use the explicit
                            LDAP search filter <LDAPFilter> specified in the
                            LDAP search filter format for searching.
                            Default:(objectCategory=*).The search filter
                            string must be enclosed in double quotes.
-attr {<AttrList> | *}      If <AttrList>, specifies a space-separated list
                            of LDAP display names to be returned for
                            each entry in the result set.
                            If *, specifies all attributes present on
                            the objects in the result set.
                            Default: distinguishedName.
-attrsonly                  Shows only the attribute types present on
                            the entries in the result set but not
                            their values.
                            Default: shows both attribute type and value.
-l                          Shows the entries in the search result set
                            in a list format. Default: table format.
{-s <Server> | -d <Domain>}
                            -s <Server> connects to the domain controller
                            (DC) with name <Server>.
                            -d <Domain> connects to a DC in domain <Domain>.
                            Default: a DC in the logon domain.
-u <UserName>               Connect as <UserName>. Default: the logged in
                            user. User name can be: user name,
                            domain\user name, or user principal name (UPN).
-p <Password>               Password for the user <UserName>. If * then you
                            are prompted for a password.
-q                          Quiet mode: suppress all output to standard
                            output.
-r                          Recurse or follow referrals during search.
                            Default: do not chase referrals during search.
-gc                         Search in the Active Directory global catalog.
-limit <NumObjects>         Specifies the number of objects matching the
                            given criteria to be returned, where <NumObjects>
                            is the number of objects to be returned.
                            If the value of <NumObjects> is 0, all matching
                            objects are returned. If this parameter is not
                            specified, by default the first 100 results are
                            displayed.
{-uc | -uco | -uci}         -uc Specifies that input from or output to pipe
                            is formatted in Unicode.
                            -uco Specifies that output to pipe or file is
                            formatted in Unicode.
                            -uci Specifies that input from pipe or file is
                            formatted in Unicode.

Remarks:
The dsquery commands help you find objects in the directory that match
a specified search criterion: the input to dsquery is a search criteria
and the output is a list of objects matching the search. To get the
properties of a specific object, use the dsget commands (dsget /?).

A user-entered value containing spaces or semicolons must be enclosed in
quotes (""). Multiple user-entered values must be separated using commas
(for example, a list of attribute types).


Examples:
To find all users in the current domain only whose SAM account name begins
with the string "jon" and display their SAM account name,
User Principal Name (UPN) and department in table format:

dsquery * domainroot
-filter "(&(objectCategory=Person)(objectClass=User)(sAMAccountName=jon*))"
-attr sAMAccountName userPrincipalName department

To read the sAMAccountName, userPrincipalName and department attributes of
the object whose DN is ou=Test,dc=microsoft,dc=com:

Dsquery * ou=Test,dc=microsoft,dc=com -scope base
-attr sAMAccountName userPrincipalName department

To read all attributes of the object whose DN is ou=Test,dc=microsoft,dc=com:

Dsquery * ou=Test,dc=microsoft,dc=com -scope base -attr *

See also:
dsquery computer /? - help for finding computers in the directory.
dsquery contact /? - help for finding contacts in the directory.
dsquery subnet /? - help for finding subnets in the directory.
dsquery group /? - help for finding groups in the directory.
dsquery ou /? - help for finding organizational units in the directory.
dsquery site /? - help for finding sites in the directory.
dsquery server /? - help for finding servers in the directory.
dsquery user /? - help for finding users in the directory.
dsquery quota /? - help for finding quotas in the directory.
dsquery partition /? - help for finding partitions in the directory.
dsquery * /? - help for finding any object in the directory by using
a generic LDAP query.

Directory Service command-line tools help:
dsadd /? - help for adding objects.
dsget /? - help for displaying objects.
dsmod /? - help for modifying objects.
dsmove /? - help for moving objects.
dsquery /? - help for finding objects matching search criteria.
dsrm /? - help for deleting objects.
dsquery failed:The parameter is incorrect.
type dsquery /? for help.
Run Code Online (Sandbox Code Playgroud)


Eli*_*ias 8

实用程序

来自 Microsoft Technet “执行与文件分配表 (FAT) 和 NTFS 文件系统相关的任务,例如管理重分析点、管理稀疏文件或卸载卷。”

其最有用的选项之一是禁用旧版 8.3 文件名的创建。这对于在具有长文件名的目录中具有大量文件的服务器特别有用。

要在 XP 或 Server 2003 上禁用旧版 8.3 文件名:

fsutil 行为设置 disable8dot3 1

在 Windows 7(可能还有 Vista 和 Server 2008)上,您将使用:

fsutil 8dot3name 设置 1

有关详细信息,请参阅:http : //technet.microsoft.com/en-us/library/cc753059.aspx


Jon*_*ker 8

配置文件

用法:

ipconfig [/? | /all | /renew [adapter] | /release [adapter] |

          /flushdns | /displaydns | /registerdns |

          /showclassid adapter |

          /setclassid adapter [classid] ]
Run Code Online (Sandbox Code Playgroud)

在哪里

adapter         Connection name 

               (wildcard characters * and ? allowed, see
Run Code Online (Sandbox Code Playgroud)

例子)

Options:

   /?           Display this help message

   /all         Display full configuration information.

   /release     Release the IP address for the specified adapter.

   /renew       Renew the IP address for the specified adapter.

   /flushdns    Purges the DNS Resolver cache.

   /registerdns Refreshes all DHCP leases and re-registers DNS names

   /displaydns  Display the contents of the DNS Resolver Cache.

   /showclassid Displays all the dhcp class IDs allowed for adapter.

   /setclassid  Modifies the dhcp class id.  
Run Code Online (Sandbox Code Playgroud)

默认是只显示 IP 地址、子网掩码和

绑定到 TCP/IP 的每个适配器的默认网关。

对于 Release 和 Renew,如果未指定适配器名称,则 IP 地址

将释放或续订绑定到 TCP/IP 的所有适配器的租用。

对于 Setclassid,如果未指定 ClassId,则删除 ClassId。

例子:

> ipconfig                   ... Show information.

> ipconfig /all              ... Show detailed information

> ipconfig /renew            ... renew all adapters

> ipconfig /renew EL*        ... renew any connection that has its 

                                 name starting with EL

> ipconfig /release *Con*    ... release all matching connections,

                                 eg. "Local Area Connection 1" or

                                     "Local Area Connection 2"
Run Code Online (Sandbox Code Playgroud)


Nei*_*eil 8

以不同的用户身份运行某些内容(有助于在没有人注销的情况下进行故障排除)

runas /U:*domainname*\*username* "*someapplication*"
Run Code Online (Sandbox Code Playgroud)

例如,如果您想使用您的凭据打开一个资源管理器窗口

runas /U:example.com\mylogin "explorer /separate"
Run Code Online (Sandbox Code Playgroud)

对于管理控制台管理单元(本示例中的服务),您需要使用 mmc 后跟普通命令来打开该管理单元

runas /U:example.com\mylogin "mmc services.msc"
Run Code Online (Sandbox Code Playgroud)

对于需要从未加入域的 PC(例如 SQL Server Management Studio)以域用户身份运行应用程序的情况

runas /netonly /U:domain\username application.exe
Run Code Online (Sandbox Code Playgroud)


Max*_*ell 8

netsh firewall set opmode disable 
Run Code Online (Sandbox Code Playgroud)

关闭 Windows 防火墙。

taskkill.exe /f /fi "status eq Not Responding"
Run Code Online (Sandbox Code Playgroud)

杀死所有没有响应的程序。


Hon*_*lex 8

我最近才发现forfiles

FORFILES [/P 路径名] [/M 搜索掩码] [/S] [/C 命令] [/D [+ | -] {MM/dd/yyyy | dd}]

描述:选择一个文件(或一组文件)并对该文件执行命令。这对批处理作业很有帮助。

我用这行来删除旧备份,这基本上删除了超过 6 天的文件:

Forfiles /p " C:\Backups\SQL " /d -6 /c "CMD /C del @FILE"
Run Code Online (Sandbox Code Playgroud)


Jos*_*ern 6

Windows 更新服务

wuauclt.exe 

/demoui
/a /ResetAuthorization
/r /ReportNow
/detectnow
Run Code Online (Sandbox Code Playgroud)

这个单一的命令有很多关于它的神话。它没有报告错误,没有帮助对话框,唯一的真正输出是为/demoui. 但它确实有效,我认为。

参考


Ken*_*nan 6

Windows Vista 和 Windows Server 2008 上的clip命令非常有用:它将任何传入的标准输入放在剪贴板上。

例子:

将当前目录复制到剪贴板:

dir | clip
Run Code Online (Sandbox Code Playgroud)

列出包含特定字符串的 C 文件:

findstr /i /s /m /c:"someFunction" *.c | clip
Run Code Online (Sandbox Code Playgroud)


bre*_*dly 6

我发现我经常需要创建大文件进行测试。

fsutil file createnew C:\1_gb-ish_file.txt 1000000000


小智 6

mstsc  # starts the Remote Desktop window.
mstsc -v 192.168.0.1  # to remotely connect to a given IP.
Run Code Online (Sandbox Code Playgroud)


jft*_*uga 6

要获取在批处理文件中使用的当前日期/时间:

for /f "usebackq tokens=1,2,3,4 delims=/ " %%w in (`echo %DATE%`) 设置 YMD=%%z%%x%%y
对于 /f "usebackq 令牌=1,2,3,4 delims=:." %%x in (`echo %TIME%`) do set HMS=%%x%%y%%z
设置现在=%YMD%_%HMS%
回声%现在%


Eug*_*iró 5

rasdial

USAGE:
    rasdial entryname [username [password|*]] [/DOMAIN:domain]
            [/PHONE:phonenumber] [/CALLBACK:callbacknumber]
            [/PHONEBOOK:phonebookfile]
            [/PREFIXSUFFIX]

    rasdial [entryname] /DISCONNECT

    rasdial

    For Online Privacy Information please refer to
    'http://go.microsoft.com/fwlink/?LinkId=34493'
Run Code Online (Sandbox Code Playgroud)

从命令行连接到 VPN 或拨号网络。


小智 5

很可能是迄今为止最强大的命令:

cmd.exe
Run Code Online (Sandbox Code Playgroud)

最喜欢的选项:

/K 执行字符串指定的命令但保持不变


小智 5

subst.exe - 将路径与驱动器号相关联,包括本地驱动器。用法示例(添加然后删除):

subst M: C:\Documents and Settings\user\My Music\
subst M: /D
Run Code Online (Sandbox Code Playgroud)

(注意:不是持久的,需要在每次登录时运行)


cop*_*152 5

最近我不得不使用: net use \\servername /d

它会终止对指定资源的权限。

另一个用途net use是以管理员身份重新挂载本地驱动器,这样您就不需要注销(在 WinXP 上,域上的切换用户被禁用)。

net use \\localShare /user:admin


fre*_*tje 5

从命令行进行磁盘管理:

diskpart
Run Code Online (Sandbox Code Playgroud)

有关详细信息,请参阅Diskpart 命令行实用程序的说明。


mpb*_*och 5

我知道这是一个老问题,但我浏览了五页的答案,但没有看到以下内容:

推送,弹出

用法:

C:\Users\MyUser\src> pushd C:\Users\MyUser\Documents
C:\Users\MyUser\Documents> cd 备份
C:\Users\MyUser\Documents\Backup> 复制 .​​.\*.* 。
C:\Users\MyUser\Documents\Backup> popd
C:\Users\MyUser\src> rem 继续在 src 目录中工作。

在长目录中工作时很有用。我想回到我原来的地方