Recently changed pages
ping arp subnet Last Edited By: quux
( 7 - days ago )
HardOfHearing Last Edited By: quux
( 14 - days ago )
Fragmentation Last Edited By: quux
( 22 - days ago )
WMIC Snippets Last Edited By: quux
( 50 - days ago )
PowerShell WMI Snippets Last Edited By: quux
( 83 - days ago )
CMD one - liners Last Edited By: quux
( 112 - days ago )
Enumerate Computers Last Edited By: quux
( 145 - days ago )
70 - 298 (Designing Security for a MS W2003 Network) Study Materials Last Edited By: quux
( 150 - days ago )
HomePage Last Edited By: quux
( 185 - days ago )
Travels Last Edited By: quux
( 185 - days ago )
more >>
Recently Attached Files
more >>
|
Newly added pages
PowerShell WMI Snippets quux ( 84 - days ago )
CMD one - liners quux ( 112 - days ago )
70 - 298 (Designing Security for a MS W2003 Network) Study Materials quux ( 150 - days ago )
Travels quux ( 185 - days ago )
71 - 680 (Win7) Study materials quux ( 210 - 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 (79 - 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) (104 - 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) (114 - 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) (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. Commented By: rob.wiese (181 - 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) (189 - 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) (253 - 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) (253 - 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) (291 - days ago), Page: WMIC Snippets
Most valuable info i have seen on the net regarding WMI!! Commented By: shop (338 - days ago), Page: WMIC Snippets
Ola, e como faço para retirar um programa com o wmic que requer uma password Commented By: Guest (344 - 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 (357 - 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 (357 - 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 (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 Commented By: Chris Sanders (363 - days ago), Page: Windows Updates
Nice job. Thanks Commented By: Guest (370 - 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 (377 - 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 Commented By: CSiebert (411 - 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 Commented By: jr (418 - days ago), Page: WMIC Snippets
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. Commented By: Paul (459 - days ago), Page: Container Housing
more>>
|