Frequently you need to process files in a folder but don’t want to deal with 0-byte files… so how do delete these pesky files in your script? Easy – in one line:

for /f “tokens=* delims=” %%F in (‘dir /s/b/a-d d:\folder’) do (if 0 equ %%~zF del “%%F”)

You can use the same technique for files that are smaller than a certain size, or bigger than a certain size by replacing EQU with LSS or GTR.

I love MAME and have wanted to build my own MAME cabinet for a long time. The closest I’ve gotten is an X-Arcade joystick mounted to a bakers rack at a comfortable height. I ran across this the other day and thought it was a nice look – retro gaming in an ultramodern shell:

Modern Mame cabinet

And how about this one for the inspiration from 1971:
1971 arcade cabinet

Source: http://www.retrothing.com/2008/08/retro-space-21s.html

By the way, in case you didn’t know, Microsoft is offering free support
on SP1… business hours only:

Free unlimited installation and compatibility support is available for
Windows Vista, but only for Service Pack 1 (SP1). This support for SP1
is valid until March 18, 2009. Availability of chat or e-mail support
differs depending on your geographic location. For customers residing in
North America or Canada, chat and e-mail support is available. Some
issues may require more advanced support for which there is a charge.

No-charge Unlimited support requests: (866) 234-6020

Microsoft publishes these numbers at support.microsoft.com/gp/oemphone
so you can get in touch with your manufacturer if you have an oem
windows license installed:

Acer (800) 816-2237
IBM (800) 426-7378
Averatec (877) 462-3462
Lenovo (866) 96-THINK (968-4465)
Compaq (800) 652-6672
Maxdata (626) 935-0050
Dell (888) 560-8324
EMachines (408) 273-0888
Medion (866) 633-4660
Fujitsu (800) 831-3183
NEC Corp (800) 338-9549
Panasonic (800) 527-8675
Gateway (800) 846-2301
Sharp (800) 237-4277
Hewlett Packard (800) 474-6836
Sony (888) 476-6972
Toshiba (800) 457-7777
Samsung www.samsung.com
Hitachi www.hitachi.com

Speaking of learning something new every day… we all know that command
line tools and spaces don’t get along… but the way to make them behave
is to surround values containing spaces in quotes, right?

So the other day I’m writing this query to extract all users in my
active directory (easy enough: dsquery user -name * -limit 50000 | sort
> users.txt).

But all the names had spaces in them and my next query, to list all the
groups each user was in (for /f “delims=~” %%i in (users.txt) do echo
%%i >> foreachuser-showgroupmembership.txt && cscript //nologo
EnumGroup.vbs %%i >> foreachuser-showgroupmembership.txt) kept bombing
out on the spaces.

So after banging my head against the wall for a couple hours, it dawns
on me to look at the help file for the FOR command.

The trick is to define a delimiter that the program will never find…
so since I knew there weren’t any ~s in the names, I set the delimiter
to ~ and re-ran the command.

This may come in handy again someday.

Get all groupnames (short):
dsquery group -limit 50000 -o samid | sort

Get all groupnames (distinguished name):
dsquery group -limit 50000 | sort

Get all users:
dsquery user -name * -limit 50000 | sort

Get all users in each group:
for /f “delims=~” %%i in (groups-SHORT.txt) do echo %%i >>
foreachgroup-showitsmembers.txt && dsquery group -name “%%i” | dsget
group -members >> foreachgroup-showitsmembers.txt && type crlf.txt >>
foreachgroup-showitsmembers.txt

Get all groups that each user is in:
for /f “delims=~” %%i in (users.txt) do echo %%i >>
foreachuser-showgroupmembership.txt && cscript //nologo EnumGroup.vbs
%%i >> foreachuser-showgroupmembership.txt && type crlf.txt >>
foreachuser-showgroupmembership.txt

So, just like hosts and lmhosts, there is a file in
\windows\sytem32\drivers\etc names ‘services’.

Now I’ve been building and maintaining PCs and networks for about 20
years and have never had to touch this file… but last week I finally
needed it.

There was an application trying to talk to a service named OLCCA… what
the hell is OLCCA? Beats me, but the developer told me it used tcp port
8562.

But how does “OLCCA” get translated to 8562? I’m glad you asked… by
defining it in the services file like this:

OLCCA 8562/tcp

You learn something new every day… if you’re paying attention.

Ran in to an interesting problem last week… the firewall on a Vista
machine wouldn’t start. Every time you tried to start it it would fail
with a “service specific error code 5″.

With not much to go on I scoured Google and support.microsoft.com but
came up empty – for a while. Then I ran across this article:
http://support.microsoft.com/kb/943996 – “Some services do not start in
Windows Vista”.

The error means “Access is denied”. This may happen if the “MpsSvc”
account doesn’t have the necessary permissions for the related registry
keys.

The NT Service\MpsSvc account needs permissions for the following keys:

1) HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Services\
SharedAccess\ Epoch: Query Value;Set Value

2) HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Services\
SharedAccess\ Parameters\ FirewallPolicy: Full Control;Read

3) HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Services\
SharedAccess\ Defaults\ FirewallPolicy: Full Control;Read

Sounded like a long-shot, but sure enough, MpsSvc had no permissions to
one of the three keys and when I added it back in, it worked. No reboot
was necessary.

© 2010 LANalyze Suffusion WordPress theme by Sayontan Sinha