《WMIC的学习过程》word版.docx
- 文档编号:7920196
- 上传时间:2023-01-27
- 格式:DOCX
- 页数:12
- 大小:19.13KB
《WMIC的学习过程》word版.docx
《《WMIC的学习过程》word版.docx》由会员分享,可在线阅读,更多相关《《WMIC的学习过程》word版.docx(12页珍藏版)》请在冰豆网上搜索。
《WMIC的学习过程》word版
WMIC的学习过程
C:
\>wmicdatafile"c:
\\hello.txt"callrenamec:
\ppp.txt
执行(\\QL-LIBOWEN\ROOT\CIMV2:
CIM_DataFile.Name="c:
\\hello.txt")->rename()
方法执行成功。
输出参数:
instanceof__PARAMETERS
{
ReturnValue=0;
};
C:
\>wmicdatafileWhere"drive='d:
'andextension='txt'andpath='\\'"getname
Name
d:
\abc.txt
d:
\复件abc.txt
WMICFSDIR别名
wmicfsdirwhere(name='c:
\\good')delete
wmicfsdirwhere(name='c:
\\good')calldelete
删除c:
\good文件夹
wmicfsdirwhere(name='c:
\\good')rename"c:
\abb"
重命名c:
\good文件夹为abb
复制文件夹
C:
\>wmicfsdirwhere(name='d:
\\test')callcopy"c:
\ppcd"
执行(\\QL-LIBOWEN\ROOT\CIMV2:
Win32_Directory.Name="d:
\\test")->copy()
方法执行成功。
输出参数:
instanceof__PARAMETERS
{
ReturnValue=0;
};
复制D盘下TEST文件夹的所有文件到C盘下的PPCD,如果PPCD存在直接复制过去,如果不存在他会自动创建并将文件复制过去
C:
\>wmicfsdirwhere(name='d:
\\test')callCompress
执行(\\QL-LIBOWEN\ROOT\CIMV2:
Win32_Directory.Name="d:
\\test")->Compress()
方法执行成功。
输出参数:
instanceof__PARAMETERS
{
ReturnValue=0;
};
压缩指定文件夹,以便节省磁盘空间
C:
\>wmicfsdirwhere(name='d:
\\test')callunCompress
执行(\\QL-LIBOWEN\ROOT\CIMV2:
Win32_Directory.Name="d:
\\test")->unCompress()
方法执行成功。
输出参数:
instanceof__PARAMETERS
{
ReturnValue=0;
};
解除压缩文件夹
Job别名
C:
\>wmicjobcallcreate"sol.exe",0,0,1,0,********154600.000000+480
执行(Win32_ScheduledJob)->Create()
方法执行成功。
输出参数:
instanceof__PARAMETERS
{
JobId=1;
ReturnValue=0;
};
这个命令和AT命令是一模一样啊,AT添加的计划任务他可以看到,他添加的同样AT命令也是可以看到
wmicjobcallcreate"sol.exe",0,0,true,false,********154800.000000+480
wmicjobcallcreate"sol.exe",0,0,1,0,********154600.000000+480
这两句是相同的,TRUE可以用1表示,同样的FALSE可以用0值表示,时间前为何用八个星号,这是WMIC的特性,他显示时间的方式是YYYYMMDDHHMMSS.MMMMMM+时区,可是,我们并不需要指定年份和月份还有天,所以用*星号来替代
Os 别名
wmicosWhere(primary='1′)callwin32shutdown*
这个*参数可以有如下值:
ConstLOGOFF=0
ConstSHUTDOWN=1
ConstREBOOT=2
ConstFORCE=4
ConstPOWEROFF=8
这些参数可以进行任意组合,例如:
强制注销:
4(0+4)的组合
强制关机:
5(1+4)的组合
强制重启:
6(2+4)的组合
强制关闭电源:
12(8+4)的组合
WMIC设置系统时间
要求需要有管理员权限
wmicoswhere(primary=1)callsetdatetime20070731144642.555555+480
执行(\\QL-LIBOWEN\ROOT\CIMV2:
Win32_OperatingSystem.Name="MicrosoftWindowsXPP
rofessional|C:
\\WINDOWS|\\Device\\Harddisk0\\Partition1″)->setdatetime()
方法执行成功。
输出参数:
instanceof__PARAMETERS
{
ReturnValue=0;
};
Process别名
C:
\>wmicprocesscallcreatesol.exe
执行(Win32_Process)->Create()
方法执行成功。
输出参数:
instanceof__PARAMETERS
{
ProcessId=3848;
ReturnValue=0;
};
C:
\>wmicprocess3848callterminate
执行(\\QL-LIBOWEN\ROOT\CIMV2:
Win32_Process.Handle="3848″)->terminate()
方法执行成功。
输出参数:
instanceof__PARAMETERS
{
ReturnValue=0;
};
可以看出PROCESS别名是以HANDLE属性为默认属性进行操作的
C:
\>wmicprocess2556callsetpriority64
执行(\\QL-LIBOWEN\ROOT\CIMV2:
Win32_Process.Handle="2556″)->setpriority()
方法执行成功。
输出参数:
instanceof__PARAMETERS
{
ReturnValue=0;
};
用来设置程序的优先权
64Idle优先权–低
16384BelowNormal优先权–低于标准
32Normal优先权–标准
32768AboveNormal优先权–高于标准
128HighPriority优先权–高
256RealTime优先权–实时
wmicprocessWhere"processid='%pid%'"callTerminate
wmicprocessWhere"name='%imagename%'"callTerminate
wmicpathWin32_Process.name="%imagename%"callTerminate
wmicpathWin32_Process.processid="%pid%"callTerminate
wmicprocessWherename='sol.exe'delete
Nicconfig别名
wmicnicconfigwhere(index='8′)callenablestatic"192.168.1.81″,"255.255.255.0″
设置IP地址和子网掩码
wmicnicconfigwhere(index='8′)callsetgateways"192.168.0.1″,1
设置网关和跃点数
wmicnicconfigwhere(index='8′)callsetdnsdomain("192.168.0.1″,"192.168.0.11″)
设置DNS服务器地址,设置完毕后不会马上生效,必需要设置主次才可以生效
wmicnicconfigwhere(index='8′)callSetDNSServerSearchOrder("192.168.0.1″,"192.168.0.11″)
设置DNS服务器地址的主次顺序,192.168.0.1在前表示为首选DNS地址,在后为备用DNS地址
wmicpathWin32_NetworkAdapterConfiguration.index=8callenabledhcp
WMIC默认的NICCONFIG别名是不提供enabledhcp这个方法的,所以我们只能调用他的WMI函数来设置动态分配IP地址的设置
wmicnicconfigwhere(index='8′)get/value INDEX值为你当前网卡的索引值,每台机器都不一样
以下为网络方面设置的各个属性值:
ArpAlwaysSourceRoute=
ArpUseEtherSNAP=
Caption=[00000008]Broadcom440x10/100IntegratedController
DatabasePath=%SystemRoot%\System32\drivers\etc
DeadGWDetectEnabled=
DefaultIPGateway={"192.168.0.1″}
DefaultTOS=
DefaultTTL=
Description=Broadcom440x10/100IntegratedController-数据包计划程序微型端口
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\defaultpathstdregprovcallgetstringvalue^&H80000002,"SOFTWARE\libowen","hello"
执行(stdregprov)->getstringvalue()
方法执行成功。
输出参数:
instanceof__PARAMETERS
{
ReturnValue=0;
sValue="IamComputerPepole!
!
!
";
};
C:
\>wmic/namespace:
\\root\defaultpathstdregprovcallcreatekey^&h80000001,"libowen\good"
—-建立libowen\good 这个键值
执行(stdregprov)->createkey()
方法执行成功。
输出参数:
instanceof__PARAMETERS
{
ReturnValue=0;
};
C:
\>wmic/namespace:
\\root\defaultpathstdregprovcalldeletekey^&h80000001,"libowen\sdd"
—删除键值SDD,注意此键值必须是最底层
执行(stdregprov)->deletekey()
方法执行成功。
输出参数:
instanceof__PARAMETERS
{
ReturnValue=0;
};
C:
\>wmic/namespace:
\\root\defaultpathstdregprovcallEnumKey^&h80000001,"KeyboardLayout"
—–枚举KeyboardLayout下的所有子键值
执行(stdregprov)->EnumKey()
方法执行成功。
输出参数:
instanceof__PARAMETERS
{
ReturnValue=0;
sNames={"preload","Substitutes","Toggle"};
};
C:
\>wmic/namespace:
\\root\defaultpathstdregprovcallEnumvalues^&h80000001,"KeyboardLayout\preload"
——–枚举KeyboardLayout\preload这个键值下的所有数值及其数值所对应的类型
执行(stdregprov)->Enumvalues()
方法执行成功。
输出参数:
instanceof__PARAMETERS
{
ReturnValue=0;
sNames={"1″,"2″,"3″};
Types={1,1,1};
};
C:
\>wmic/namespace:
\\root\defaultpathstdregprovcallSetStringValue^&h80000001,"libowen\test","helloworld!
","test"
——建立一个名为test的string的数值,值为helloworld!
执行(stdregprov)->SetStringValue()
方法执行成功。
输出参数:
instanceof__PARAMETERS
{
ReturnValue=0;
};
C:
\>wmic/namespace:
\\root\defaultpathstdregprovcallSetStringValue^&h80000001,"libowen\test","test","aabb"
—–修改aabb的数值为test
执行(stdregprov)->SetStringValue()
方法执行成功。
输出参数:
instanceof__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:
\>wmicpagefilesetget/value
Caption=C:
\‘pagefile.sys'
Description='pagefile.sys'@C:
\
InitialSize=384
MaximumSize=768
Name=C:
\pagefile.sys
SettingID=pagefile.sys@C:
用来察看本地计算机虚拟内存情况,初始大小,最大值,保存位置等
下面我们可以改变虚拟内存文件(也就是我们常说的页面文件)所在位置以及初始大小和最大值
wmicpagefilesetsetinitialsize=512,maximumsize=1024
这个只是改变初始大小和最大值,SET不能修改页面文件所存放的位置,也就是说默认页面文件在C盘这时不能把他的位置修改到D盘,如果要修改到D盘我们可以这样来做
wmicpagefilesetcreatename='d:
\pagefile.sys',initialsize=512,maximumsize=1024
然后删除以前的就可以了,请看
wmicpagefilesetwhere(name='c:
\\pagefile.sys')delete
这样就实现了把页面文件转移到D盘的效果
WMIC设置代理服务器
C:
\>wmicpathwin32_proxyget/value
Caption=
Description=
ProxyPortNumber=
ProxyServer=:
ServerName=ql-libowen.ql-
SettingID=
C:
\>wmicpathwin32_proxyWhereServerName='ql-libowen.ql-'callsetproxysetting"8080″,"192.168.1.59″
执行(\\QL-LIBOWEN\root\cimv2:
Win32_Proxy.ServerName="ql-libowen.ql-")->s
etproxysetting()
方法执行成功。
输出参数:
instanceof__PARAMETERS
{
ReturnValue=0;
};
C:
\>wmicpathwin32_proxy.servername="ql-libowen.ql-"callsetproxysetting"",""
执行(\\QL-LIBOWEN\root\cimv2:
Win32_Proxy.ServerName="ql-libowen.ql-")->s
etproxysetting()
方法执行成功。
输出参数:
instanceof__PARAMETERS
{
ReturnValue=0;
};
WMIC设置共享
输入参数是OBJECT类型
原因:
对于OBJECT类型的输入参数,还没有实现全面支持。
默认值(空字符串:
"")是目前支持的唯一值。
解决方案:
使用下面的命令为三个用户设置c:
\test目录的共享:
WMICSHARECALLCreate"","test","3″,"TestShareName","","c:
\test",0
建立共享文件夹
C:
\>WMICSHAREwhere(path='c:
\\test')calldelete
执行(\\QL-LIBOWEN\ROOT\CIMV2:
Win32_Share.Name="TestShareName")->delete()
方法执行成功。
输出参数:
instanceof__PARAMETERS
{
ReturnValue=0;
};
WMIC对于共享文件夹操作
C:
\>WMICSHAREwhere(path='c:
\\test')delete
删除范例\\QL-LIBOWEN\ROOT\CIMV2:
Win32_Share.Name="TestShareName"
范例删除成功。
Type(共享类型)
Typeofresourcebeingshared.Typesinclude:
diskdrives,printqueues,interprocesscommunications(IPC),andgeneraldevices.
ValueMeaning
0—–DiskDrive
1—–PrintQueue
2—–Device
3—–IPC
2147483648—-DiskDriveAdmin
2147483649—-PrintQueueAdmin
2147483650—-DeviceAdmin
2147483651—-IPCAdmin
Computersystem 别名
wmiccomputersystemWhere"name='原计算机名称'"callrename"要修改的计算机名"
主要功能:
修改计算机名称
wmiccomputersystemWhere"name='计算机名称'"calljoindomainorworkgroup"","","MyGroup"
主要功能:
更改现有工作组为指
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- WMIC的学习过程 WMIC 学习 过程 word