Useful Scripts? Please: Don’t Ask


As I’ve noted before, Microsoft really isn’t anything at all like its reputation. For example, we’re supposed to be the ruthless corporate bulldozer that simply crushes any human being that dares get in our way; in truth, though, we are probably the most politically-correct and overly-sensitive company in the history of the universe. Take our documentation (please!). In the Windows 2000 Scripting Guide, for example, I had a sentence that read something like this:


 


Learning to write scripts is no different than learning to play baseball: if you want to be good at it, you have to be willing to practice.


 


Not the exact sentence, but you get the idea.


 


So what’s wrong with that? Well, supposedly, soccer is the most popular sport in the world; therefore, I couldn’t use the word baseball. Why? Because soccer fans would somehow be offended. I was told it was OK to use the word soccer, but that didn’t make a lot of sense to me: after all, wouldn’t baseball fans then be offended? In the end, we just yanked the sentence altogether. (I mean, not that it was a great sentence or anything. It was just the principle of the thing.)


 


In another place in the book I said something along these lines:


 


In many respects, choosing a scripting language is similar to choosing a car: the model you pick depends on what you need to do. If all you need to do is get from Point A to Point B, then it probably doesn’t matter ….


 


I just realized that this could make for an interesting game show: For $500, tell me what is inappropriate about the preceding paragraph? If you said, “Nothing,” well, sorry, but we do have some lovely parting gifts for you. As was pointed out to me, not everyone in the world owns a car; therefore, we couldn’t use a car as an analogy. When I protested that even people who don’t own cars have likely heard of cars, the reply was, “Maybe. But you don’t know that for sure, do you?” Therefore, to avoid offending the one system administrator in the world who can still manage his or her Windows 2000 network despite having never heard of a car, we were supposed to remove this paragraph. (Did we actually remove it? To tell you the truth, I don’t even remember.)


 


As you might expect, it’s difficult to write a blog under these circumstances. Blogs, by definition, are supposed to be at least somewhat opinionated, but I don’t think the folks around here would be too thrilled if I started ranting and raving about the burning issues of the day. Therefore, I won’t bring up the fact that the Washington men’s basketball team whipped top-ranked and previously-unbeaten Stanford 75-62 on Saturday. And I won’t mention that the Huskies, who also beat Arizona twice this year, finished second in the Pac-10 with a 12-6 record. Nor will I mention that sports commentators seem to universally believe that the UW does not deserve a bid to the NCAA basketball tournament. Why? Well, for heaven’s sake, if we let the second-place team from the Pac-10 in, then we might not have room for the eighth-place team from the ACC! Good grief; what kind of a tournament would it be if we didn’t allow in a team that managed to finish 8th in a 9-team conference? That’s right: a travesty.


 


But although I have strong feelings about all this, you won’t hear a peep out of me. No, sir.


 


In the spirit of uncertainty surrounding the Huskies’ chances of going to the NCAA tournament (hopefully they’ll just win the Pac-10 tournament, and then the NCAA will have to let the Huskies in), I present a couple of scripts I’ve had lying around for years (I think they were originally written by my great-great-great-great-grandfather, and have been passed down through the family for generations). A long time ago, I somehow or another stumbled upon the Shell.LocalMachine COM class, and discovered you could write a script to get some interesting information about the local computer:


 


Set objComputer = CreateObject(“Shell.LocalMachine”)


Wscript.Echo “Computer name: ” & objComputer.MachineName


Wscript.Echo “Shutdown allowed: ” & objComputer.IsShutdownAllowed


Wscript.Echo “Friendly UI enabled: ” & objComputer.IsFriendlyUIEnabled


Wscript.Echo “Guest access mode: ” & objComputer.IsGuestAccessMode


Wscript.Echo “Guest account enabled: ” & _


    objComputer.IsGuestEnabled(0)


Wscript.Echo “Multiple users enabled: ” & _


    objComputer.IsMultipleUsersEnabled


Wscript.Echo “Offline files enabled: ” & _


    objComputer.IsOfflineFilesEnabled


Wscript.Echo “Remote connections enabled: ” & _


    objComputer.IsRemoteConnectionsEnabled


Wscript.Echo “Undock enabled: ” & objComputer.IsUndockEnabled


 


How useful is this? I don’t know, but some of it looks like it might be applicable to system administrators. (For example, off the top of my head, I’m not sure how else to determine whether or not offline files or remote connections are enabled on a machine.) This class also has a couple of methods that make it really easy to enable and disable the Guest account. For example, here’s a script that enables the Guest account:


 


set objComputer = CreateObject(“Shell.LocalMachine”)


objComputer.EnableGuest(1)


 


And here’s one that disables the Guest account:


 


set objComputer = CreateObject(“Shell.LocalMachine”)


objComputer.DisableGuest(0)


 


Are these the coolest bits of scripting code you’ll ever see? Hey, I don’t want to offend anyone, so I have no opinion whatsoever. They are what they are.


 


Here’s one I’m even less sure about. It tells you the name of the Passport account currently in use, as well as the member services URL for that Passport account:


 


Set objUser = CreateObject(“UserAccounts.PassportManager”)


Wscript.Echo “Current passport: ” & objUser.CurrentPassport


Wscript.Echo “Member services URL: ” & objUser.MemberServicesURL


 


What would you use something like this for? Well, that’s entirely up to you; my job is just to pass along crazy little tidbits of information like this.


 


And one final script, just for the heck of it. This one returns the name and Product ID (PID) for all the Microsoft applications installed on a computer. Useful or not useful? Hey, we report, you decide:


 


Set objMSInfo = CreateObject(“MsPIDinfo.MsPID”)


colMSApps = objMSInfo.GetPIDInfo()


 


For Each strApp in colMSApps


    Wscript.Echo strApp


Next


 


By the way, I think these are Windows XP-only scripts. I hope those of you who don’t have Windows XP aren’t too upset by this. If you are, feel free to complain; just get in line behind the soccer fans and the system administrators who have never heard of cars before.


 


 


Comments (19)

  1. CC says:

    "Learning to write scripts is no different than learning to play baseball: if you want to be good at it, you have to be willing to practice"

    Probably because no-one outside of the US plays baseball 🙂

    If you said Football then it means something in the US, and the rest of the world knows what you really mean (no-one outside of the US says soccer, we all say football). I think I should petition to have American Football renamed to American Rugby, it’s probably closer.

  2. Anonymous says:

    This post just reeks of typical MS arrogance. The following line really stands out:

    " the way, I think these are Windows XP-only scripts. I hope those of you who don’t have Windows XP aren’t too upset by this. If you are, feel free to complain; just get in line behind the soccer fans and the system administrators who have never heard of cars before. "

  3. Dave says:

    Sheesh. How are you supposed to make a sports reference, then? You can’t use football (American football is pretty much a US & Canada only thing, and refering to that other game as football is going to drive Americans nuts). Can’t use soccer (unpopular in the US & Canada, and Microsoft is, after all, an American company; also calling the game soccer will drive non-North Americans nuts). Can’t use baseball (unpopular in Europe, and non-Americanized Asian countries). Can’t use basketball (unpopular in Asia, Yao nonwithstanding). Can’t use hockey (see basketball, except there’s not even Yao). What’s left?

  4. Scott says:

    agreed, UW should be considered for an at large bid.

    http://scottkoon.org/journal/wp-trackback.php/163

    CC, be sure to tell all those people in Japan that they aren’t really playing Baseball. I’ll stop by and tell Ichiro later this afternoon.

    All those Cubans and people in the Dominican Republic need to be informed as well. Sammy Sosa is going to be confused. "How did I learn to play Baseball if no one outside the U.S. plays Baseball?"

  5. Alex Angelopoulos says:

    Easy fix. Use:

    "Your Favorite Sport" or YFS ™.

  6. Alex Angelopoulos says:

    FYI….

    People can also query remote systems this way. Just use the remote machine’s name as an argument tp the GetPIDInfo method call.

    Mr. Stemp knew that of course… he was just waiting to see who would catch on. 😐

  7. Hmmm … ‘football’ in Australia means Rugby League, and soccer is soccer (aka ‘the world game’). How about using rugby? Enough people around the world play that … even though 90% of them won’t understand it.

    Better yet, make some reference to the Olympics, EVERYONE has heard of that, right?

    BTW: Calling American Football American Rugby is just an insult to rugby fans … although with a few more NFLers in the team perhaps the Eagles could really go somewhere next World Cup!

  8. CC says:

    Scott said: CC, be sure to tell all those people in Japan that they aren’t really playing Baseball. I’ll stop by and tell Ichiro later this afternoon.

    All those Cubans and people in the Dominican Republic need to be informed as well. Sammy Sosa is going to be confused. "How did I learn to play Baseball if no one outside the U.S. plays Baseball?"

    Sorry will re-phrase that to only 4 countries in the whole world play baseball 😉 What’s that ? Out of around about 200 countries ?

    ( http://www.infoplease.com/countries.html )

  9. Take Outs for 8 March 2004

  10. Dave says:

    Really, baseball is extraordinarily popular in the Caribean, and quite popular in North America, northern South America, Japan, Taiwan, and South Korea. There are players in the US majors from 18 countries, though three of them are places where baseball is of neglible interest (Australia, the UK, and Germany).

  11. Work at home moms. Work from home moms. Moms work from home. Kevin thompson work at home moms.