All Comments(33)

quux(79 - days ago)Page: Windows Updates

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?

Will (Guest)(103 - 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

Damir (Guest)(113 - days ago)Page: HomePage

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.

quux (Guest)(180 - days ago)Page: Ping

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.

rob.wiese(180 - 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.

Rob (Guest)(189 - days ago)Page: WMIC Snippets

Nice intro!!

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

Rob

preetsangha@gmail.com+(Guest)(253 - days ago)Page: NETSH many ports

Just a thought - could to speed it up slightly by doing them in parallel? cmd /c netsh - perhaps?

preet Sangha (Guest)(253 - days ago)Page: WMIC Snippets

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

- Preet
http://preetsangha.blogspot.com

Guest (Guest)(290 - 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!

shop(337 - days ago)Page: WMIC Snippets

Most valuable info i have seen on the net regarding WMI!!

Guest(343 - days ago)Page: WMIC Snippets

Ola, e como faço para retirar um programa com o wmic que requer uma password

quux(356 - 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.

quux(356 - 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.

Chris Sanders(363 - days ago)Page: Windows Updates

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

Chris Sanders(363 - 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

Guest(370 - days ago)Page: BladeServers

Nice job. Thanks

bryan(376 - days ago)Page: WMIC Snippets

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.

CSiebert(410 - days ago)Page: WMIC Snippets

The best WMI introduction with practical use that I've seen so far.

Hope to see more examples in the future! ;-)

Best regards,

Chris

jr(417 - days ago)Page: WMIC Snippets

Olá quux,

great introduction into WMI and the best thing that happened to me this week :-) If you don't know: I found the link to your page on Wikipedia's article about WMI.

With the best greetings from Portugal!

Muito obrigado,
jr

Paul(458 - days ago)Page: Container Housing

Let's see, you criticize a legit trade organization (ISBA) then tell us to buy from the two companies in your post. mmm, you are either selling advertising or you are a shipping container salesman for one of the companies you plug.

Guest(460 - days ago)Page: WMIC Snippets

Thank you Thank you Thank you


Excellent webpage, a lot of useful information.


Brgds.

Rafael

Guest(463 - days ago)Page: Container Housing

the isbu is b.s. - its a bunch of container salesman trying to lather up their resumes with all these letters. who else is a member of the isbu besides the owners of isbu? what a bunch of baloney. McKinney and Global Portable projects are good

Guest(472 - days ago)Page: WMIC Snippets

You save my day!!! Best regards from Brazil

quux(496 - days ago)Page: WMIC Snippets

Hey, Bob. You found a 'gotcha': the wmic product query does not work on Windows 2003 until you install the 'WMI Windows Installer Provider' via Add/Remove programs. I have updated the page to explain this.


Keep the questions coming!

bob(496 - days ago)Page: WMIC Snippets

infact it just doesnt work. here is out put from a simple wmic product command:wmic product get Vendor
Node - MyComputer
ERROR:
Code = 0x80041010
Description = Invalid class
Facility = WMI

Bob(496 - days ago)Page: WMIC Snippets

Great This. I wanted to try to get a particular product,say antivirus version. how do i go about it. am running on windows server 2003 and it says invalid class. Here's the command:
c:\>wmic product where name="AntiVirusProduct" get version

quux(497 - days ago)Page: WMIC Snippets

I really appreciate the compliments. This started out as a sort of cheatsheet for my own use. Glad to see others are finding it useful!


-quux

Chili(503 - days ago)Page: WMIC Snippets

Excelent page! has cleared a lot of doubts regarding WMI.


Thank You!.

quux(532 - days ago)Page: Container Housing

1) For the links on this page, I think so, but peruse the links for confirmation. The Ace units do not look to be tandard shipping units, though 'built to same dimensions'


2) no

Guest(532 - days ago)Page: Container Housing

i'm interested, but two questions:

1) are these acually ISO shipping containers (ISBU's)?

2) are you a member of the ISBU Association?

Guest(542 - days ago)Page: Container Housing

You may be interested in the Ace modular building units which can be used as a standalone unit or component of a larger structure. It is compact for transportation and storage, easily assembled/dissassembled with hand tools on site, and can be configured (both interior space and exterior windows/doors) for many applications. Go to www.aceamericas.com

Guest(561 - days ago)Page: Laser Printer Wireless

I don't know about printers, so i can't tell about it sorry.

,,,,,,,,,,,,,,,,,,,,,,,
GAYATHRI

Great printer toner and ink cartridge deals, discounts and coupons. Also, check out the latest printer reviews and technology news. http://blog.concordsupplies.com

Guest(563 - days ago)Page: WMIC Snippets

Awsome guide - Thanks!!!!