Pages

June 26, 2014

WMIC Tips

Overview


WMIC (Windows Management Instrumentation Command-Line) extends WMI for operation from several command-line interfaces and through batch scripts.


Command Examples

-- Display installed applications



c:\wmic product get name
c:\wmic /node:"computername" product list > c:\output.txt

-- Uninstall An Application
c:\wmic product where name="ApplicationName" call uninstall
c:\WMIC /node:"computername" product where name="applicationName" call uninstall
c:\WMIC /node:"computer" /user:"domain\userid" /password:"yourpassword" product where name="applicationName" call uninstall

-- Get Serial Number
C:\wmic bios get serialnumber

-- Close an applications
c:\wmic process where name=”iexplore.exe” call terminate

-- Start an application
c:\wmic process call create “paint.exe”

-- To get the process list
c:\wmic process list

-- To get the macaddress of nic card
c:\wmic nic get macaddress,description

-- To change DNS server
c:\wmic nicconfig where (IPEnabled=TRUE and DHCPEnabled=FALSE)
call SetDNSServerSearchOrder (“192.168.254.101”,“192.168.254.100”)
c:\wmic /node:“rv-wk-test-01” process call create “netsh interface ip set dns local static “10.1.1.1”"
c:\wmic /node:“rv-wk-test-01” process call create “netsh interface ip add dns local static “10.1.1.1”"

-- Disable System restore
wmic /node:computer /namespace:\\root\default path SystemRestore call Disable c:\
wmic /namespace:\\root\default path SystemRestore call Disable %SystemDrive%\

-- Automatic pagefile management
wmic.exe computersystem where name=”%computername%” set AutomaticManagedPagefile=True

1.  To get the process list – wmic process list
2.  To get the group list – wmic group list
3.  To get the NIC Card Configuration – wmic nicconfig list
4.  To get user account list – wmic useraccount list
5.  To get the built in System account list – wmic sysaccount list
6.  To get the Environment list – wmic environment list
7.  To get the information of all shares (including hidden) – wmic share list
8.  To get the list of services – wmic services list
9.  To get the computer system details – wmic computersystem list
10. To get the volume information – wmic volume list
11. To get full startup list – wmic startup list full
12. To get Information of logical disks – wmic logicaldisk get description, filesystem, name, size
13. To get screensaver information – wmic desktop get screensaversecure, screensavertimeout
14. To get logon information – wmic logon get authenticationpackage
15. To get information about the OS – wmic os get name, servicepackmajorversion
16. To get information about QFE (Quick Fix Engineering) – wmic qfe get description,installedOn
17. To get information about the computer – wmic csproduct get name,vendor,identifyingNumber
18. To get the toal ram – wmic computersystem get TOTALPhysicalMemory,caption
19. To get the macaddress of nic card – wmic nic get macaddress,description
Note: In all the above you can use “brief” command to get a brief list of information and “full” to get the full list of information, for example use wmic process list brief, wmic process list full.
Doing some niche tasks from wmic:
1. Update static ip address
wmic nicconfig where index=9 call enablestatic("192.168.0.117"),("255.255.255.0")

2. To Change the network gateway
wmic nicconfig where index=9 call setgateways("192.168.0.117","192.168.0.118"),(1,2)

3. To start an application
wmic process call create “paint.exe”

4. To enable dhcp
wmic nicconfig where index=9 call enabledhcp

5. To kill an application
wmic process where name=”paint.exe” call terminate

6. To change the process priority
wmic process where name=”iexplorer.exe” call setpriority 64

7. To get name and process id of a process
wmic process where (Name=’svchost.exe’) get name,processid

2 comments: