今天分享一些工作中比较实用的命令技巧,对于Windows系统使用和故障处理比较有帮助。
1.1 找到java.exe这个程序的进程ID及所运行的命令行
wmic process where caption="java.exe" get processid,caption,commandline /value
1.2 查找进程ID为6196执行文件的路径
wmic process where ProcessId=6196 get ExecutablePath
1.3 查找notepad.exe这个程序的进程ID和会话等相关信息
tasklist /fi "imagename eq notepad.exe"
1.4 查看svchost.exe进程的子服务
tasklist /SVC /FI "IMAGENAME eq svchost.exe"
1.5 在远程主机上192.168.0.114调用cmd.exe执行命令,并将结果写入到txt文件
wmic /node:192.168.0.100 /user:administrator /password:<password> process call create "cmd.exe /c whowmi>D:\result.txt"
有时候会遇到Windows主机资源耗尽的情况,此时已经不能通过远程桌面的方式登录系统,而
net use占用的资源很少,可以用这种方式远程重启
对192.168.0.100的主机进行强制重启操作,立即执行。
net use \\192.168.0.100 "<password>" /user:administrator
shutdown -r -f -t 0 -m \\192.168.0.100
3.1 连接网络共享并映射为驱动器 Z:
net use Z: \\192.168.0.100\sharedfolder <password> /user:administrator
3.2 设置连接并保持映射,即使重启后依然有效:
net use Z: \\192.168.0.100\sharedfolder /persistent:yes
3.3 断开网络驱动器连接
net use Z: /delete
3.4 删除所有网络驱动器连接
net use * /delete
4.1 例如注册SAPRouter服务
sc create SAPRouter binPath= "C:\saprouter\saprouter.exe service -r -R C:\saprouter\SAPROUTTAB" start= auto obj= "NT AUTHORITY\LocalService"
4.2 关闭或启动服务
sc stop/start SAPRouter
4.3 删除服务
sc delete SAPRouter
5.1 查看时间同步源
w32tm /query /source
5.2 查看时间同步状态
w32tm /query /status
5.3 指定外部时间源并与之同步
w32tm /config /manualpeerlist:"ntp3.aliyun.com" /syncfromflags:manual /reliable:yes /update
5.4 显示本地时间与目标时间差
w32tm /stripchart /computer:ntp3.aliyun.com /samples:30 /dataonly
5.5 手动同步时间
w32tm /resync
今天的分享就到这里了,欢迎留言交流~