Dashboard



Recently changed pages



Fragmentation 
Last Edited By: quux  ( 5 - days ago )

windows ops! 
Last Edited By: quux  ( 10 - days ago )

WMIC Snippets 
Last Edited By: quux  ( 33 - days ago )

PowerShell WMI Snippets 
Last Edited By: quux  ( 66 - days ago )

CMD one - liners 
Last Edited By: quux  ( 94 - days ago )

Enumerate Computers 
Last Edited By: quux  ( 128 - days ago )

70 - 298 (Designing Security for a MS W2003 Network) Study Materials 
Last Edited By: quux  ( 132 - days ago )

HomePage 
Last Edited By: quux  ( 168 - days ago )

Travels 
Last Edited By: quux  ( 168 - days ago )

71 - 680 (Win7) Study materials 
Last Edited By: quux  ( 183 - days ago )

more >>

Recently Attached Files



71-680-prep-materials.PNG [view]
Uploaded by : quux (193 - days ago )

perfmon-paging.png
Uploaded by : quux (425 - days ago )

WIndows Installer Provider.PNG
Uploaded by : quux (479 - days ago )

sb-tartancz0.png
Uploaded by : quux (660 - days ago )

sb-conversationoddwy6.png
Uploaded by : quux (660 - days ago )

sb-tapelu8.png
Uploaded by : quux (660 - days ago )

sb-footerau2.gif [view]
Uploaded by : quux (660 - days ago )

sb-headercq3.png
Uploaded by : quux (660 - days ago )

sb-contentip3.png
Uploaded by : quux (660 - days ago )

more >>

Newly added pages  



windows ops!
quux  ( 10 - days ago )
PowerShell WMI Snippets
quux  ( 67 - days ago )
CMD one - liners
quux  ( 95 - days ago )
70 - 298 (Designing Security for a MS W2003 Network) Study Materials
quux  ( 133 - days ago )
Travels
quux  ( 168 - days ago )


Recent comments



Hi Will:

Sorry it took me so long to see this comment and respond. Are you running the script from an account which is a member of Administrators?
Commented By: quux  (62 - days ago ), Page: Windows Updates

Awesome script, though I'm having problems running it remotely on Vista machines. I get the following problem via psexec

6 update(s) found. 6 eligible for install by this script.
(This script will NOT download/install updates with I, H, N, or L properties.)
(Updates with the E property will be installed if /accepteula arg was given.)

Installing the updates. Again, it takes time.
C:\forinstall.vbs(265, 17) Microsoft VBScript runtime error: Permission denied
Commented By: Will (Guest)  (86 - days ago ), Page: Windows Updates

Thanks for great info.
I linked to WMIC Snippets in my blog. I hope you dont mind that reference is just fantastic.
Like yourself I also use windows and *nixes and to be honest I prefer linux, but nevertheless I got tired of always listening how inferior cmd is to *nix shell, so I wrote a blog post on that few days back.
http://www.damirkucic.com/2009/07/cmdexe-tribute-to-old-friend.html
I hope I'm not to arrogant linking to it in comment but it's so "connected" with your thoughts on quuxutils (I'm linking too soon) page that I just had to.

Anyway thanks again for fantastic reference and some of your stuff is definitely bookmark.
Commented By: Damir (Guest)  (97 - days ago ), Page: HomePage

Rob, thanks for mentioning the || operator. I don't use it enough, I admit.

But it doesn't really fit well in this script, because I often change the -n argument to 2 or more. In that way I can send multiple pings to the address, but still indicate success (host is up and reachable) if one or more pings get through.
Commented By: quux (Guest)  (163 - days ago ), Page: Ping

Hey! Nice web site. You and I are solving similar sysadmin problems.

You can simplify your ping test and use actual host names by using the logical_or "||" or logical_and "&&" symbols.

ping -n 1 %1 > nul || @goto pingfail
goto ping success

Focus passes through the || only if ping fails (ie errorlevel 1).

Steven Wettberg's Alive.exe program returns errorlevels for several different types of failures: ttl expired, bad destination, etc. So if you're testing for more types of failures, Alive.exe might be a better choice than ping.exe - ymmv.

Alive.exe might be a good candidate for your quuxutils collection.


Rob W.
Commented By: rob.wiese  (163 - days ago ), Page: Ping

Nice intro!!

Any ideas on returning a processes componenents, paths and versions? Like listdlls would produce?

Rob
Commented By: Rob (Guest)  (172 - days ago ), Page: WMIC Snippets

Just a thought - could to speed it up slightly by doing them in parallel? cmd /c netsh - perhaps?
Commented By: preetsangha@gmail.com+(Guest)  (236 - days ago ), Page: NETSH many ports

Excellent article. I've posted a link back here from my blog

- Preet
http://preetsangha.blogspot.com
Commented By: preet Sangha (Guest)  (236 - days ago ), Page: WMIC Snippets

Does anyone know how to delimit the ampersand? \ does not work. I need to get a mac address based on the pnpdeviceid but the string is breaking on the &.


wmic nic where "PNPDeviceID=PCI\VEN_xxxx&Dev_xxx&..." get macaddress

gets error: dev_xxxx is not recognized as an interna or external command.

(this repeat for each part of the string after the &


Help!
Commented By: Guest (Guest)  (273 - days ago ), Page: WMIC Snippets

Most valuable info i have seen on the net regarding WMI!!
Commented By: shop  (321 - days ago ), Page: WMIC Snippets

thank you . . . this worked great with the calcnetworkID fix
Commented By: Guest  (324 - days ago ), Page: ping arp subnet

Ola, e como faço para retirar um programa com o wmic que requer uma password
Commented By: Guest  (327 - days ago ), Page: WMIC Snippets

CSiebert, I add to the page whenever I discover new stuff. Today I'm adding a couple more little bits.
Commented By: quux  (340 - days ago ), Page: WMIC Snippets

Hi bryan - I've never used Install Anywhere, so I have no idea how it would affect/instantiate WMI/WMIC. Sorry about that.
Commented By: quux  (340 - days ago ), Page: WMIC Snippets

The Attachments link below didn't work the way I expected it to. I'll try posting the patch inline.


<pre>

--- wupdate.txt 2008-11-25 13:30:34.322862400 -0800

wupdate.vbs 2008-11-25 13:30:45.000000000 -0800

@@ -10,8 10,8 @@



Dim colArgs

set colArgs = Wscript.Arguments.Named

-HandleArgs

UseCscript

HandleArgs

CheckWuaVersion



'global vars and the updateSearcher object

@@ -44,6 44,7 @@

if colArgs.Exists("?") Then HelpExit

if colArgs.Exists("help") Then HelpExit

if colArgs.Exists("-help") Then HelpExit

If colArgs.Exists("checkonly") And colArgs.Count > 1 Then HelpExit

end sub



sub UseCscript 'make sure we are running in cscript - warn and exit if not

@@ -133,7 134,6 @@

sub ListUpdatesNeeded 'print list of updates needed

'list all updates that are not language packs - and their download status

'update properties: http://msdn.microsoft.com/en-us/library/aa386099(VS.85).aspx

-'TODO: skip updates that require EULA checks. or have a commandline that accepts the EULA

Wscript.Echo

Dim RequestsInput, WantsReboot, HighImpact, NeedsNetwork, LanguagePack, DontInstall

Dim Eula, I, update, downloadstatus, downloadcount

@@ -149,6 149,7 @@

End If

For I = 0 To searchResult.Updates.Count-1

DontInstall = 0

downloadstatus = "-"

RequestsInput = "-"

WantsReboot = "-"

HighImpact = "-"

@@ -165,8 166,6 @@

If colArgs.Exists("accepteula") = False Then

DontInstall = DontInstall 1

Else

- updatesToDownload.Add(update)

- updatesToInstall.Add(update)

update.AcceptEula()

End If

End If

@@ -183,17 182,16 @@

DontInstall = DontInstall 1

End If

If update.InstallationBehavior.RebootBehavior <> 0 Then WantsReboot = "R"

- If update.IsDownloaded Then

- downloadstatus = "-"

- If DontInstall = 0 Then updatesToInstall.Add(update)

- Else

If Not update.IsDownloaded Then

downloadstatus = "D"

If DontInstall = 0 Then

updatesToDownload.Add(update)

- updatesToInstall.Add(update)

End If

End If

- WScript.Echo " "& downloadstatus & WantsReboot & RequestsInput & HighImpact & NeedsNetwork & LanguagePack & Eula &_

If DontInstall = 0 Then

updatesToInstall.Add(update)

End If

WScript.Echo " "& downloadstatus & WantsReboot & RequestsInput & HighImpact & NeedsNetwork & Eula & LanguagePack &_

" "& update.Title

Next

Wscript.Echo

@@ -350,7 348,7 @@

strComputer = "."

Set oWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colOSInfo = oWMIService.ExecQuery("Select * from Win32_OperatingSystem")

-'I dislike looping through just to get one property. But dunno another way!

' We must loop to find the instance; ItemIndex wasn't implemented until Vista.

For Each oOSProperty in colOSInfo

strCaption = oOSProperty.Caption

Next
Commented By: Chris Sanders  (346 - days ago ), Page: Windows Updates

Hi quux, great script. I like your attention to error handling.


I tested the script on Windows XP SP2. I'm using it to build an OSD reference image automatically. Here are a few things I noticed:


1. You probably meant to call UseCscript before calling HandleArgs.


2. Nothing prevents users from using /checkonly with the other options. It looks like your intention is to make /checkonly read-only, but if you also supply the /accepteula option it will modify the system and produce different results on the second run.


3. Updates are added to the download and install lists in two places. For some updates, like Windows XP Service Pack 3, this causes them to be added to the install list even though they require user input (because they also require a EULA). An additional side effect is that updates with EULAs will be added to the lists twice.


4. The EULA and LanguagePack columns are reversed relative to the header.


5. Minor cosmetic issues: For some reason the highlighting software removed the spaces where "Call DownloadFile" appears, which prevented the script from running after a simple copy and paste. Also, the "If update.IsDownloaded Then" clause is indented as though it's subordinate to the prior line... that threw me for a sec. Finally, downloadcount and strOSFamily (in OSFamily) are declared but not used.


I've already fixed items 1-4 above; I'll attach the patch in a minute. Thanks for writing this.

-Chris Sanders
Commented By: Chris Sanders  (346 - days ago ), Page: Windows Updates

Nice job. Thanks
Commented By: Guest  (353 - days ago ), Page: BladeServers

This is a very useful introduction, Thanks!

I have been trying to use WMIC with the tool Install Anywhere to determine what is already installed so that I can skip installing components which are already available. Mostly useful for upgrading, and makes my life easier (faster) when testing the installer.

The issue I have having is that when I execute WMIC from my Install Anywhere executable it hangs if run as a batch. If I run as a single command, the command will not execute until the installer has completed. I am starting to guess that WMIC is in use by Install Anywhere so it cannot complete until the install is over. This is just a guess, but if you have any information I'd appreciate it. WMIC just seems perfect for an install/uninstall because you can use the Windows Add/Remove to clean up or detect an existing application.
Commented By: bryan  (359 - days ago ), Page: WMIC Snippets

you should change line 147

CalcNetworkIP --> CalcNetworkID

It's should be worked.
Commented By: Jerry Wang  (384 - days ago ), Page: ping arp subnet

It doesn't work!

CalcNetworkIP = Undefined variable in line 147!!
Commented By: Guest  (390 - days ago ), Page: ping arp subnet

more>>