设置账号和密码永不过期

2017年9月11日 20:27

  • * 查看用户信息
PS C:\Users\wyq> net user wyq
用户名                 wyq
全名
注释
用户的注释
国家/地区代码          000 (系统默认值)
帐户启用               Yes
帐户到期               从不

上次设置密码           2016/1/19 17:46:52
密码到期               从不
密码可更改             2016/1/19 17:46:52
需要密码               No
用户可以更改密码       Yes

允许的工作站           All
登录脚本
用户配置文件
主目录
上次登录               2017/8/30 10:09:58

可允许的登录小时数     All

本地组成员             *Administrators       *Performance Log Users
全局组成员             *None
命令成功完成。
 
  • 帐号永不过期
net user username  password  /add /expires:never
 
  • 密码永不过期
wmic UserAccount where "Name='username'" set PasswordExpires=False
 
此生必看的科学实验-水知道答案
精神病为什么治不好
贤公和尚,佛门榜样
 

 

Tags: windows
评论(0) 阅读(3248)

删除几天前的文件

2017年7月15日 06:39

  • 删除10天前的文件
(Get-Childitem).where{$_.LastWriteTime -lt (Get-Date).AddDays(-10)} |rm

Get-Childitem 查询当前目录下的文件
Get-Date.AddDays(-10) 当前时间向前退10天

此生必看的科学实验-水知道答案


 

Tags: windows
评论(11) 阅读(6934)

cacls查看文件权限

2017年7月15日 06:21

PS C:\> cacls .\099260b8-7e81-4d4c-8970-c637011399bf.txt
C:\099260b8-7e81-4d4c-8970-c637011399bf.txt BUILTIN\Administrators:(ID)F
                                            NT AUTHORITY\SYSTEM:(ID)F
                                            BUILTIN\Users:(ID)R

  • F 表示完全控制
  • C 表示更改
  • W 表示写入
  • R 表示读取

 

Tags: windows
评论(6) 阅读(2452)

如何判断windows版本?

2017年6月20日 21:48

 
windows版本名称太多,怎么通过版本号,取得对应的版本名称?
 
  • 版本号与市场名称的关系
在微软与IBM分家的时候Windows操作系统改名叫做Windows NT,第一个版本是Windows NT 3.1。
后来由于市场需要,在每次发布Windows之前,都会给Windows NT取个别名
也就是xp、win7、win8。例如下面的Version 10.0.14393,其实是Windows NT的版本号。
 
只要清楚NT版本号与名称的映射关系,就可以通过版本号得到名称
 
  • 获取版本号(powershell)
PS C:\Users\wyq> Get-WmiObject Win32_OperatingSystem

SystemDirectory : C:\WINDOWS\system32
Organization    :
BuildNumber     : 14393
RegisteredUser  : wyq
SerialNumber    : 00330-80000-00000-AA130
Version         : 10.0.14393
  • 映射关系
Windows NT 3.1    Windows NT 3.1
Windows NT 3.5    Windows NT 3.5
Windows NT 3.51   Windows NT 3.51
Windows NT 4.0    Windows NT 4.0
Windows NT 5.0    Windows 2000
Windows NT 5.1    Windows xp
Windows NT 5.2    Windows xp、Windows Server 2003、Wwindows Server 2003 R2
Windows NT 6.0    Windows Vista、Windows Server 2008
Windows NT 6.1    Windows 7、Windows Server 2008 R2
Windows NT 6.2    Windows 8、Windows Phone 8、Windows Server 2012
Windows NT 6.3    Windows Phone 8.1、Windows Server 2012 R2
Windows NT 6.4    Windows 10(技术预览版)
Windows NT 10.0   Windows 10
对照映射表,10.0.14393就是Windows 10
 
此生必看的科学实验-水知道答案
精神病为什么治不好
百病之源
净土大经科注2014

 

Tags: powershell windows
评论(0) 阅读(2858)

查看windows磁盘剩余空间

2017年4月17日 22:57

  • 在powershell中运行Get-Volume
PS C:\Users\Administrator> Get-Volume

DriveLetter FileSystemLabel FileSystem DriveType HealthStatus OperationalStatus SizeRemaining      Size
----------- --------------- ---------- --------- ------------ ----------------- -------------      ----
G                           NTFS       Fixed     Healthy      OK                    320.86 GB 372.61 GB
            系统保留        NTFS       Fixed     Healthy      OK                    301.87 MB    350 MB
C                           NTFS       Fixed     Healthy      OK                    881.36 GB 931.17 GB
                            NTFS       Fixed     Healthy      OK                    931.31 GB 931.51 GB

 

Tags: hyper-v windows volume
评论(10) 阅读(3108)

windows命令查看软件安装情况

2017年4月09日 14:07

在windows上,可以通过控制面板,查看软件安装情况。那么除此之外还有其它方法吗?
 
  • powershell命令
PS C:\Users\wyq> Get-WmiObject -class Win32_Product |Select-Object -Property name,version

name                                                                                                 version
----                                                                                                 -------
Microsoft Visual C++ Compiler Package for Python 2.7                                                 9.0.1.30729
Microsoft .NET Framework 4.5.1 Multi-Targeting Pack                                                  4.5.50932
Microsoft Visual C++  x64-x86 Cross Compilers - CHS Resources                                        12.0.21005
Microsoft SQL Server 2012 T-SQL Language Service                                                     11.1.3000.0
....
 

Tags: powershell windows
评论(1) 阅读(2372)

powershell递归删除文件

2016年9月26日 20:50

  • 在powershell上执行
get-childitem * -include *.pyc -recurse |remove-item
  • 或者使用别名
ls * -include *.pyc -recurse |rm

 

Tags: windows
评论(42) 阅读(4341)

cmd切换为administrator用户

2016年9月26日 19:46

runas /noprofile /user:Administrator cmd
  • runas         允许用户用其它权限运行指定的工具和程序
  • /noprofile    指定不应该加载用户的配置文件。
  • /user:UserAccountName  指定在其下运行程序的用户帐户的名称
 

Tags: windows DOS runas
评论(1) 阅读(6222)