The VBScript Network and Systems Administrator's Cafe


February 26, 2009  8:00 AM

Retrieving the account IIS is using as the anonymous user account with VBScript

Jerry Lees Jerry Lees Profile: Jerry Lees

I recently posted a script that retrieved the anonymous user password for a server in IIS. This script I posted, Using the IIS ADSI object to retrieve the anonymous user password for a server via VBScript, came in quite handy in a pinch, but not knowing the anonymous user account the password goes with can also be a pain.Luckily I had that piece of information in the script as well!

So, I’ve wrapped that part of the script into a function for your use as well. Below is a snippet from the script to display the user account.

Function Get_IUSR_Username(ServerName)
Dim IIsObject

Set IIsObject = GetObject (“IIS://” & ServerName & “/w3svc”)
on Error resume Next
Get_IUSR_Username = IIsObject.Get(“AnonymousUserName”)
On Error GoTo 0
End Function

Enjoy!

February 20, 2009  3:53 PM

Using the IIS ADSI object to retrieve the anonymous user password for a server via VBScript

Jerry Lees Jerry Lees Profile: Jerry Lees

I recently had to change the anonymous user account for a change request for a site in IIS, but unfortunately the change did not work and we had to roll it back. However, I didn’t have and wouldn’t have known the account’s password since IIS and windows changes it periodically.

So, out came the scripting tool belt and I found that I had a script written previously that let me get the anonymous user account and password through the IIS ADSI object.

Below is a snippet from the script to display the password.

Function Get_IUSR_Password(ServerName)
   Dim IIsObject
   
   Set IIsObject = GetObject (“IIS://” & ServerName & “/w3svc”)
   on Error resume Next
   Get_IUSR_Password = IIsObject.Get(“AnonymousUserPass”)
   On Error GoTo 0
End Function

Enjoy!


February 13, 2009  6:40 PM

Creating a unique GUID for use in your VBScripts

Jerry Lees Jerry Lees Profile: Jerry Lees

Today I answered a question in the ITKE unanswered questions for Word VBA on how to be certain a filename was unique across several users using it. The answer I gave answered the question, but I knew there was a way to create GUID’s within VBScript but couldn’t recall how.

GUID’s are cryptic to look at, but they are pretty much guaranteed to be unique. After some research I found the library that provides this functionality… Scriptlet.TypeLib! Below is a short script that gives you an idea of how to use it in your scripts to generate unique strings for when you need a guaranteed unique name or identifier.

Option Explicit

Dim GUID
Set TypeLib = CreateObject(“Scriptlet.TypeLib”)
GUID = TypeLib.Guid

Enjoy!


February 10, 2009  6:11 PM

Easily compare dates from with in VBScript

Jerry Lees Jerry Lees Profile: Jerry Lees

On occasion you need to compare two dates in your scripts, this can be a real challenge when you approach the date as if it were a string and/or compare the date parts to one another. Then finding the difference can be a whole other set of challenges if your dates span several months, days, or years.

Luckily, there is a function right into VBScript that helps you compare two dates to one another and returns the difference in a unit of time that you specify! That function is the datediff function!

Below is an example that returns the number of seconds, minutes, hours, days, and years between now and February 25, 1973.

Option Explicit

Dim DateThen, DateNow

DateThen = “2/25/1973″
DateNow = Now

WScript.Echo DateDiff(“s”,DateThen, DateNow)
WScript.Echo DateDiff(“n”,DateThen, DateNow)
WScript.Echo DateDiff(“h”,DateThen, DateNow)
WScript.Echo DateDiff(“d”,DateThen, DateNow)
WScript.Echo DateDiff(“yyyy”,DateThen, DateNow)

Enjoy!


February 5, 2009  2:32 PM

New high-end enterprise search solution revealed from Microsoft

Jerry Lees Jerry Lees Profile: Jerry Lees

 Apparently, Microsoft’s Live search wasn’t good enough… so like every normal Multi-Billion dollar company would do, They bought another one. Read below:

Here’s an update on the great results from Microsoft’s acquisition of enterprise search developer FAST Search & Transfer last April. As you may recall, the plan was to bring together FAST’s deep search expertise with the widely used SharePoint Server platform technology. Today, Microsoft gave out some details on FAST Search for SharePoint, a new search server that will add the high-end search capabilities of FAST ESP to SharePoint.

You can read more about the search buy-out here, New high-end enterprise search solution revealed.


February 2, 2009  7:12 PM

BlogJetThis! extension for Firefox 3 Fixes Firefox plugin installation error

Jerry Lees Jerry Lees Profile: Jerry Lees

This really isn’t Systems Administration related, but I recently started using a tool called blogjet to write blog entries and had a hard of a time getting the extensions to work properly in Firefox. It was telling me that the BlogJetThis! extension was not compatible with Firefox 3.0.6.

Essentially, It looks like it was installing a Firefox 2 extension… even though the extension said it was for “< 2.0”. A quick google search found this article that solved the issue.

 BlogJet extension for Firefox 3.


January 30, 2009  1:30 AM

Easy String Searches with the VBScript Instr function

Jerry Lees Jerry Lees Profile: Jerry Lees

I recently had a situation where I needed to find string inside a string to parse the larger string into usable and separate chunks of data. In writing this script, I realized I’ve not shared this gem of a function with you previously… and it really makes matters easier when you are manipulating strings.

That function is the Instr function. When configured with the proper parameters, by default, it will return the FIRST location in a string where a sub-string occurs. (Hint: this is where a mid() function would come in handy after you have that starting location). If the sub-string is not found, the function returns 0. The syntax is as follows:

Instr(StartPostion, StringToSearch,StringtoFind, Compare)

 

 The script I wrote really is a blog entry of it’s own, and will be, but I wanted to first introduce you to this great function and let you have a chance to play with it and see some code in action. Below is an example script that takes a string and searched for specific sub strings, then returns the location in the string where the sub string occurs.

 

Option explicit
Dim StrSource

StrSource = “Now I can find a word In a long string of words in a sentance.”

WScript.Echo(InStr(1,StrSource,”In”))
WScript.Echo(InStr(1,StrSource,”in”))
WScript.Echo(InStr(1,StrSource,” in “))
WScript.Echo(InStr(1,StrSource,”now”))

Below is the output from the script. Notice, the following:

  • The case of in and In in the sub-string being searched for and the positions it returns?
  • Notice the substring “in ” returns something entirely different?
  • Notice the substring now returns 0?

 

23
12
48
0

 

Enjoy!


January 28, 2009  11:40 PM

Microsoft CRM Email Router stops working mysteriously and then starts working again– just as mysteriously.

Jerry Lees Jerry Lees Profile: Jerry Lees

I’ve been doing a good deal of work with Microsoft CRM lately. Heck, I’ll say it… I’ve been doing ALL my work with Microsoft CRM lately. It’s a beast that no one here at “the office” knows about and I’ve become “The Guy”. You know what that means, scramble to stay ahead of the game and get the environment under control before it blows up in your face!

Well, recently I learned a couple things about the CRM Email router service. This post is the first thing I learned, and I found an article that states exactly what is happening:

You use the Microsoft Dynamics CRM 4.0 E-Mail Router service to process e-mail messages. After a specific period of time, the service stops processing e-mail messages. Then, after the same period of time, the service starts to process e-mail messages again.

Essentially that’s what was happening to me, CRM would send e-mail messages for about an hour then the messages would queue up for a while before being sent again. Really great when those messages are time sensitive… talk about keeping a guy up all night!

You can read all about the solution here, but basically the Microsoft Dynamics CRM 4.0 Update Rollup 1 fixes the problem, though I imagine you could adjust the  ConfigUpdatePeriod mentioned in the article and get a little bit of tweaking out of it in the short term while you test the update in a non-production environment like all good systems admins do. ;-)

Enjoy!


January 23, 2009  7:21 PM

Tip: Searching Google for solutions to a Microsoft product problem

Jerry Lees Jerry Lees Profile: Jerry Lees

Maybe this isn’t earth shattering, and most all of you already know this trick. However, I just stumbled upon it and am willing to bet at least a few people are troubled by searching google for answers to problems and finding the needle in the haystack. Here’s the scenario:\

You’re looking for Microsoft Knowledge Base articles on a error your getting with a particular Microsoft application and using google to do the search because you can search better with it compared to the Microsoft site. However, you get so much noise back in your results in links to pages that were never solved, the solution is ambiguous, or (frankly) the solutions that are given are coming from sources where you simply question which end of the gene pool they are standing in at the time they wrote the proposed answer… you know what I’m talking about. Those guys that give answers like Format and call me back later or “Re-install the OS to get the drivers updated”.

Well, I suddenly noticed a trend at the bottom of some KB articles I had to call MS to get an answer to a problem. They are tagging the articles with key words! Yes, I know it’s not earth shattering. However, the following might help you.

For troubleshooting articles, it seems they always tag it with: kbtshoot

For articles that mention a event log error message they always tag it with: kberrmsg

Soooo…. If you need to search google for a Microsoft product KB article put this in as part of your search! It greatly limits the number of noisy results in your search! For example, you get trouble shooting KB articles for Microsoft CRM try this in a Google search:

kbtshoot “Microsoft CRM”

Of course that’s very generic… but hopefully you get the idea. Enjoy!


January 19, 2009  4:14 AM

Windows Tip: Clearing Internet Explorer cached data from the command line

Jerry Lees Jerry Lees Profile: Jerry Lees

As a Network Administrator sometimes you need to clear the browsing history, cookies, or the like for a entire community of users. Sure, you could tell them how to do it thinking that you were being super smart by providing instructions for them. However, as you well know there will be some who will be unable to follow the directions and you will spend 3 times the amount of time it took you to write the directions and refine them to a point where any one could do it— or so you thought. All the while, thinking about the amount of time you will save by having the users do it.

Why not be really lazy!!!??!? And do it with a batch script? You could then put it in their login script and it would happen at their next logon, or every logon for that matter. Well, there’s an easy way to do this with windows’ built in functions– it’s just obscure enough to not be found anywhere you would normally look!

Yo can preform many of the things I mentioned (and more) with Microsoft’s RUNDLL.EXE file, plus you don’t have to write a line of VBScript to accomplish the task!

Here is a short list of some tasks you can preform on IE, along with the command to do it… give them a shot!

Temporary Internet Files
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8

Cookies
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2

History
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1

Form Data
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16

Passwords
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32

Delete All
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255

Delete All – “Also delete files and settings stored by add-ons”
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351

 These commands should work in Internet Explorer 7


Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: