常用Dos 命令

本文介绍了如何使用telnet检查特定端口的状态,利用netstat查看所有打开的端口,以及如何通过DOS命令获取系统日期和时间。此外,还详细解释了如何利用环境变量和字符串截取技巧获取精确的时间格式,以及使用tzutil命令管理和查询系统时区。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

telnet ip 端口号:检查端口是否打开

netstat -an:查看已打开的所有端口

------------------------------------------------------------------------------------------------------

获取日期和时间

C:\>echo %date%

Wed 11/13/2013

C:\>echo %time%
12:32:37.89

C:\>echo %date:~0,3%
Wed

%date%是一个参数,后面带的~0,3表示取值范围

~表示从环境变量的内容的左边开始,~m,n: m表示从第m个字符开始,n表示取n个字符

~0,3意思是从头开始取3个字符,所以为Wed

C:\>echo %date:~-4%

2013 

~-4: 负数代表倒数,也就取最后4个字符

C:\>echo %date:~-7,-5%
13

~-7,-5: 取最后7个字符,并且不显示其中最后5个

C:\>echo %date:~-7,5%
13/20

~-7,5: 取最后7个字符,并且不显示其中前5个

C:\>echo %date:~-4%-%date:~-7,-5%-%date:~-10,-8% %time:~0,2%_%time:~3,2%_%time:~6,2%

2013-13-11 12_29_44

--------------------------------------------------------------------------------------------------------------------------------------------

 Tzutil: Displays the Windows Time Zone Utility. For more details, see http://technet.microsoft.com/en-us/library/hh875624.aspx

  tzutil [/?] [/g] [/s <TimeZoneID>[_dstoff]] [/l]

ParameterDescription

/?

Displays Help at the command prompt.

/g

Displays the current time zone ID.

/s <TimeZoneID>[_dstoff]

Sets the current time zone using the specified time zone ID. The _dstoff suffix disables Daylight Saving Time adjustments for the time zone (where applicable).

/l

Lists all valid time zone IDs and display names. The output will be:

  • <display name>
  • <time zone ID>

 

 

转载于:https://www.cnblogs.com/jenneyblog/archive/2013/03/07/DosCommands.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值