| 关键词: wmic LIBOWEN call Where Name ReturnValue 成功 参数 PARAMETERS instance |
Datafile 别名 C:\>wmic datafile "c:\\hello.txt" call rename c:\ppp.txt 执行 (rename'>\\QL-LIBOWEN\ROOT\CIMV2:CIM_DataFile.Name="c:\\hello.txt")->rename() 方法执行成功。 输出参数: instance of __PARAMETERS { ReturnValue = 0; }; C:\>wmic datafile Where "drive='d:' and extension='txt' and path='\\'" get name Name d:\abc.txt d:\复件 abc.txt WMIC FSDIR别名 wmic fsdir where(name='c:\\good') delete wmic fsdir where(name='c:\\good') call delete 删除c:\good文件夹 wmic fsdir where(name='c:\\good') rename "c:\abb" 重命名c:\good文件夹为abb 复制文件夹 C:\>wmic fsdir where(name='d:\\test') call copy "c:\ppcd" 执行 (copy'>\\QL-LIBOWEN\ROOT\CIMV2:Win32_Directory.Name="d:\\test")->copy() 方法执行成功。 输出参数: instance of __PARAMETERS { ReturnValue = 0; }; 复制D盘下TEST文件夹的所有文件到C盘下的PPCD,如果PPCD存在直接复制过去,如果不存在他会自动创建并将文件复制过去 C:\>wmic fsdir where(name='d:\\test') call Compress 执行 (Compress'>\\QL-LIBOWEN\ROOT\CIMV2:Win32_Directory.Name="d:\\test")->Compress() 方法执行成功。 输出参数: instance of __PARAMETERS { ReturnValue = 0; }; 压缩指定文件夹,以便节省磁盘空间 C:\>wmic fsdir where(name='d:\\test') call unCompress 执行 (unCompress'>\\QL-LIBOWEN\ROOT\CIMV2:Win32_Directory.Name="d:\\test")->unCompress() 方法执行成功。 输出参数: instance of __PARAMETERS { ReturnValue = 0; }; 解除压缩文件夹 Job 别名 C:\>wmic job call create "sol.exe",0,0,1,0,********154600.000000+480 执行 (Win32_ScheduledJob)->Create() 方法执行成功。 输出参数: instance of __PARAMETERS { JobId = 1; ReturnValue = 0; }; 这个命令和AT命令是一模一样啊,AT添加的计划任务他可以看到,他添加的同样AT命令也是可以看到 wmic job call create "sol.exe",0,0,true,false,********154800.000000+480 wmic job call create "sol.exe",0,0,1,0,********154600.000000+480 这两句是相同的,TRUE可以用1表示,同样的FALSE可以用0值表示,时间前为何用八个星号,这是WMIC的特性,他显示时间的方式是YYYYMMDDHHMMSS.MMMMMM+时区 ,可是,我们并不需要指定年份和月份还有天,所以用*星号来替代 Os 别名 wmic os Where (primary='1′) call win32shutdown * 这个*参数可以有如下值: Const LOGOFF=0 Const SHUTDOWN=1 Const REBOOT=2 Const FORCE=4 Const POWEROFF=8 这些参数可以进行任意组合,例如: 强制注销:4 (0+4)的组合 强制关机:5 (1+4)的组合 强制重启:6 (2+4)的组合 强制关闭电源:12 (8+4)的组合 WMIC设置系统时间 要求需要有管理员权限 wmic os where(primary=1) call setdatetime 20070731144642.555555+480 执行 (\\QL-LIBOWEN\ROOT\CIMV2:Win32_OperatingSystem.Name="Microsoft Windows XP P rofessional|C:\\WINDOWS|\\Device\\Harddisk0\\Partition1″)->setdatetime() 方法执行成功。 输出参数: instance of __PARAMETERS { ReturnValue = 0; }; Process 别名 C:\>wmic process call create sol.exe 执行 (Win32_Process)->Create() 方法执行成功。 输出参数: instance of __PARAMETERS { ProcessId = 3848; ReturnValue = 0; }; C:\>wmic process 3848 call terminate 执行 (terminate'>\\QL-LIBOWEN\ROOT\CIMV2:Win32_Process.Handle="3848″)->terminate() 方法执行成功。 输出参数: instance of __PARAMETERS { ReturnValue = 0; }; 可以看出PROCESS别名是以HANDLE属性为默认属性进行操作的 C:\>wmic process 2556 call setpriority 64 执行 (setpriority'>\\QL-LIBOWEN\ROOT\CIMV2:Win32_Process.Handle="2556″)->setpriority() 方法执行成功。 输出参数: instance of __PARAMETERS { ReturnValue = 0; }; 用来设置程序的优先权 64 Idle 优先权-低 16384 Below Normal 优先权-低于标准 32 Normal 优先权-标准 32768 Above Normal 优先权-高于标准 128 High Priority 优先权-高 256 Real Time 优先权-实时 wmic process Where "processid='%pid%'" call Terminate wmic process Where "name='%imagename%'" call Terminate wmic path Win32_Process.name="%imagename%" call Terminate wmic path Win32_Process.processid="%pid%" call Terminate wmic process Where name='sol.exe' delete Nicconfig 别名 wmic nicconfig where(index='8′) call enablestatic "192.168.1.81″,"255.255.255.0″ 设置IP地址和子网掩码 wmic nicconfig where(index='8′) call setgateways "192.168.0.1″,1 设置网关和跃点数 wmic nicconfig where(index='8′) call setdnsdomain ("192.168.0.1″,"192.168.0.11″) 设置DNS服务器地址,设置完毕后不会马上生效,必需要设置主次才可以生效 wmic nicconfig where(index='8′) call SetDNSServerSearchOrder ("192.168.0.1″,"192.168.0.11″) 设置DNS服务器地址的主次顺序,192.168.0.1在前表示为首选DNS地址,在后为备用DNS地址 wmic path Win32_NetworkAdapterConfiguration.index=8 call enabledhcp WMIC默认的NICCONFIG别名是不提供enabledhcp这个方法的,所以我们只能调用他的WMI函数来设置动态分配IP地址的设置 wmic nicconfig where(index='8′) get /value INDEX值为你当前网卡的索引值,每台机器都不一样 以下为网络方面设置的各个属性值: ArpAlwaysSourceRoute= ArpUseEtherSNAP= Caption=[00000008] Broadcom 440x 10/100 Integrated Controller DatabasePath=%SystemRoot%\System32\drivers\etc DeadGWDetectEnabled= DefaultIPGateway={"192.168.0.1″} DefaultTOS= DefaultTTL= Description=Broadcom 440x 10/100 Integrated Controller - 数据包计划程序微型端口 DHCPEnabled=FALSE DHCPLeaseExpires= DHCPLeaseObtained= DHCPServer= DNSDomain=("192.168.0.1″,"192.168.0.11″) DNSDomainSuffixSearchOrder= DNSEnabledForWINSResolution=FALSE DNSHostName=ql-libowen DNSServerSearchOrder={"192.168.0.1″,"192.168.0.11″} DomainDNSRegistrationEnabled=FALSE ForwardBufferMemory= FullDNSRegistrationEnabled=TRUE GatewayCostMetric={1} IGMPLevel= Index=8 IPAddress={"192.168.0.81″} IPConnectionMetric=20 IPEnabled=TRUE IPFilterSecurityEnabled=FALSE IPPortSecurityEnabled= IPSecPermitIPProtocols={"0″} IPSecPermitTCPPorts={"0″} IPSecPermitUDPPorts={"0″} IPSubnet={"255.255.255.0″} IPUseZeroBroadcast= IPXAddress= IPXEnabled=FALSE IPXFrameType= IPXMediaType= IPXNetworkNumber= IPXVirtualNetNumber= KeepAliveInterval= KeepAliveTime= MACAddress=00:0F:1F:4F:08:A0 MTU= NumForwardPackets= PMTUBHDetectEnabled= PMTUDiscoveryEnabled= ServiceName=bcm4sbxp SettingID={B97AA60A-483E-4C84-84FE-5A3C6A875B65} TcpipNetbiosOptions=0 TcpMaxConnectRetransmissions= TcpMaxDataRetransmissions= TcpNumConnections= TcpUseRFC1122UrgentPointer= TcpWindowSize= WINSEnableLMHostsLookup=TRUE WINSHostLookupFile= WINSPrimaryServer= WINSScopeID= WINSSecondaryServer= WMIC对注册表的操作 C:\>wmic /namespace:\\root\default path stdregprov call getstringvalue ^&H80000002,"SOFTWARE\libowen","hello" 执行 (stdregprov)->getstringvalue() 方法执行成功。 输出参数: instance of __PARAMETERS { ReturnValue = 0; sValue = "I am Computer Pepole!!!"; }; C:\>wmic /namespace:\\root\default path stdregprov call createkey ^&h80000001,"libowen\good" --建立libowen\good 这个键值 执行 (stdregprov)->createkey() 方法执行成功。 输出参数: instance of __PARAMETERS { ReturnValue = 0; }; C:\>wmic /namespace:\\root\default path stdregprov call deletekey ^&h80000001,"libowen\sdd" -删除键值SDD,注意此键值必须是最底层 执行 (stdregprov)->deletekey() 方法执行成功。 输出参数: instance of __PARAMETERS { ReturnValue = 0; }; C:\>wmic /namespace:\\root\default path stdregprov call EnumKey ^&h80000001,"Keyboard Layout" --枚举Keyboard Layout下的所有子键值 执行 (stdregprov)->EnumKey() 方法执行成功。 输出参数: instance of __PARAMETERS { ReturnValue = 0; sNames = {"preload", "Substitutes", "Toggle"}; }; C:\>wmic /namespace:\\root\default path stdregprov call Enumvalues ^&h80000001,"Keyboard Layout\preload" ---枚举Keyboard Layout\preload这个键值下的所有数值及其数值所对应的类型 执行 (stdregprov)->Enumvalues() 方法执行成功。 输出参数: instance of __PARAMETERS { ReturnValue = 0; sNames = {"1″, "2″, "3″}; Types = {1, 1, 1}; }; C:\>wmic /namespace:\\root\default path stdregprov call SetStringValue ^&h80000001,"libowen\test","hello world!","test" --建立一个名为test的string的数值,值为hello world! 执行 (stdregprov)->SetStringValue() 方法执行成功。 输出参数: instance of __PARAMETERS { ReturnValue = 0; }; C:\>wmic /namespace:\\root\default path stdregprov call SetStringValue ^&h80000001,"libowen\test","test","aabb" --修改aabb的数值为test 执行 (stdregprov)->SetStringValue() 方法执行成功。 输出参数: instance of __PARAMETERS { ReturnValue = 0; }; REG_SZ (1) REG_EXPAND_SZ (2) REG_BINARY (3) REG_DWORD (4) REG_MULTI_SZ (7) HKEY_CLASSES_ROOT (0×80000000) HKEY_CURRENT_USER (0×80000001) HKEY_LOCAL_MACHINE (0×80000002) HKEY_USERS (0×80000003) HKEY_CURRENT_CONFIG (0×80000005) HKEY_DYN_DATA (0×80000006) Pagefileset 别名 C:\>wmic pagefileset get /value Caption=C:\ ‘pagefile.sys' Description='pagefile.sys' @ C:\ InitialSize=384 MaximumSize=768 Name=C:\pagefile.sys SettingID=pagefile.sys @ C: 用来察看本地计算机虚拟内存情况,初始大小,最大值,保存位置等 下面我们可以改变虚拟内存文件(也就是我们常说的页面文件) 所在位置以及初始大小和最大值 wmic pagefileset set initialsize=512,maximumsize=1024 这个只是改变初始大小和最大值,SET不能修改页面文件所存放的位置,也就是说默认页面文件在C盘这时不能把他的位置修改到D盘,如果要修改到D盘我们可以这样来做 wmic pagefileset create name='d:\pagefile.sys',initialsize=512,maximumsize=1024 然后删除以前的就可以了,请看 wmic pagefileset where(name='c:\\pagefile.sys') delete 这样就实现了把页面文件转移到D盘的效果 WMIC设置代理服务器 C:\>wmic path win32_proxy get /value Caption= Description= ProxyPortNumber= ProxyServer=: ServerName=ql-libowen.ql-art.com SettingID= C:\>wmic path win32_proxy Where ServerName='ql-libowen.ql-art.com' call setproxysetting "8080″,"192.168.1.59″ 执行 (s'>\\QL-LIBOWEN\root\cimv2:Win32_Proxy.ServerName="ql-libowen.ql-art.com")->s etproxysetting() 方法执行成功。 输出参数: instance of __PARAMETERS { ReturnValue = 0; }; C:\>wmic path win32_proxy.servername="ql-libowen.ql-art.com" call setproxysetting "","" 执行 (s'>\\QL-LIBOWEN\root\cimv2:Win32_Proxy.ServerName="ql-libowen.ql-art.com")->s etproxysetting() 方法执行成功。 输出参数: instance of __PARAMETERS { ReturnValue = 0; }; WMIC 设置共享 输入参数是 OBJECT 类型 原因:对于 OBJECT 类型的输入参数,还没有实现全面支持。默认值(空字符串:"")是目前支持的唯一值。 解决方案:使用下面的命令为三个用户设置 c:\test 目录的共享: WMIC SHARE CALL Create "","test","3″,"TestShareName","","c:\test",0 建立共享文件夹 C:\>WMIC SHARE where(path='c:\\test') call delete 执行 (delete'>\\QL-LIBOWEN\ROOT\CIMV2:Win32_Share.Name="TestShareName")->delete() 方法执行成功。 输出参数: instance of __PARAMETERS { ReturnValue = 0; }; WMIC对于共享文件夹操作 C:\>WMIC SHARE where(path='c:\\test') delete 删除范例 \\QL-LIBOWEN\ROOT\CIMV2:Win32_Share.Name="TestShareName" 范例删除成功。 Type (共享类型) Type of resource being shared. Types include: disk drives, print queues, interprocess communications (IPC), and general devices. Value Meaning 0--Disk Drive 1--Print Queue 2--Device 3--IPC 2147483648--Disk Drive Admin 2147483649--Print Queue Admin 2147483650--Device Admin 2147483651--IPC Admin Computersystem 别名 wmic computersystem Where "name='原计算机名称'" call rename "要修改的计算机名" 主要功能:修改计算机名称 wmic computersystem Where "name='计算机名称'" call joindomainorworkgroup "","","MyGroup" 主要功能:更改现有工作组为指定的工作组 wmic computersystem Where "name='计算机名称' call UnjoinDomainOrWorkgroup 主要功能:退出所在域 wmic computersystem Where "name='计算机名称'" call joindomainorworkgroup "",1,"域名称","域管理员密码","域管理员用户名" 例如:想要加入到的域名称为QLART ,域管理员用户名应该为 [email protected] 或qlart\administrator 密码为:XXXXXX Useraccount 别名 C:\>wmic useraccount where(LocalAccount='1′ and name='good') set disabled=true 更新 ‘\\QL-LIBOWEN\ROOT\CIMV2:Win32_UserAccount.Domain="QL-LIBOWEN",Name="good"‘的属性 属性更新成功。 C:\>wmic useraccount where(LocalAccount='1′ and name='good') set fullname="hello world!" 更新 ‘\\QL-LIBOWEN\ROOT\CIMV2:Win32_UserAccount.Domain="QL-LIBOWEN",Name="good"‘的属性 属性更新成功。 C:\>wmic useraccount where(localaccount=true and name='good') set passwordchangeable=true 更新 ‘\\QL-LIBOWEN\ROOT\CIMV2:Win32_UserAccount.Domain="QL-LIBOWEN",Name="good"‘的属性 属性更新成功。 C:\>wmic useraccount Where "domain='ql-libowen' and name='libowen'" set PasswordExpires=false 更新 ‘\\QL-LIBOWEN\ROOT\CIMV2:Win32_UserAccount.Domain="QL-LIBOWEN",Name="libowen"‘ 的属性 属性更新成功。 |
|
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|