Why isn't this VB script working under Win2003 (worked under Win2000)
Results 1 to 7 of 7

Thread: Why isn't this VB script working under Win2003 (worked under Win2000)

  1. #1
    Senior Member
    Join Date
    Apr 2004
    Posts
    157

    Question Why isn't this VB script working under Win2003 (worked under Win2000)

    Hey!
    I'm not really a programmer, but a year ago I had a need of cycling the log for an Apache server (running on Win2000) we have, so I dug into trying to make my own VB script and it turned out to work very well.
    Today I just upgraded the server to Win2003, and now the script won't run anymore.. !
    Since it was a year ago when I made it, and I haven't messed with VB scripts since, I don't even remember why/how I made the script, and what could cause it to not work anymore.

    Anyone out there who might know what could cause this script to not work anymore?!

    Big thanks in advance!!

    Dim strService
    strService = "WebCT"
    strComputer = "."
    Const EVENT_SUCCESS = 0
    Set objEmail = CreateObject("CDO.Message")
    objEmail.From = "WebCTscript@mydomain.com"
    objEmail.To = "SawPer@mydomain.com"
    Set objShell = Wscript.CreateObject("Wscript.Shell")
    set objComputer = GetObject("WinNT://myDomain/" + strComputer + ",computer")
    set objNTService = objComputer.GetObject("service", strService)

    If objNTService.status <> 4 Then
    objShell.LogEvent EVENT_SUCCESS, "VerifyWebCTService - WebCT was NOT running, check for problems! Service Status = " & objNTService.status
    objEmail.Subject = "WebCT service problems!"
    objEmail.Textbody = "WebCT Service was NOT running! Check for problems! Service status = " & objNTService.status
    objEmail.Send
    objNTService.start
    objShell.LogEvent EVENT_SUCCESS, "VerifyWebCTService - WebCT was started. Service status = " & objNTService.status
    wscript.quit
    Else
    objShell.LogEvent EVENT_SUCCESS, "VerifyWebCTService - WebCT Service was running!"

    End If
    The error message I get is:
    Script: VBscript.vbs
    Line: 10
    Char: 1
    Error: An invalid directory pathname was passed
    Code: 80005000
    Source: Active Directory

  2. #2
    Super Moderator: GMT Zone nihil's Avatar
    Join Date
    Jul 2003
    Location
    United Kingdom: Bridlington
    Posts
    17,178
    OK.................I have absolutely no idea so:

    1. Please check your directory paths (sorry, I don't know Win2003Server...........2000 was my last)
    2. Try this: http://www.computerperformance.co.uk...e_80005000.htm
    3. Recompile the source under Win2003............should show syntax errors

    Not that I noticed any....

    Good luck
    If you cannot do someone any good: don't do them any harm....
    As long as you did this to one of these, the least of my little ones............you did it unto Me.
    What profiteth a man if he gains the entire World at the expense of his immortal soul?

  3. #3
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,255

    Re: Why isn't this VB script working under Win2003 (worked under Win2000)

    Well you'd have to step through, but my guess is that your path is actually bad.

    Consider:
    Code:
    strComputer = "."
    Path is: "WinNT://myDomain/.,computer"
    Is . even a valid computer name under 2k3?

    MSDN is a wonderful tool: http://msdn.microsoft.com/library/de...nt_adspath.asp
    Chris Shepherd
    The Nelson-Shepherd cutoff: The point at which you realise someone is an idiot while trying to help them.
    \"Well as far as the spelling, I speak fluently both your native languages. Do you even can try spell mine ?\" -- Failed Insult
    Is your whole family retarded, or did they just catch it from you?

  4. #4
    Regal Making Handler
    Join Date
    Jun 2002
    Posts
    1,668
    set objComputer = GetObject("WinNT://myDomain/" + strComputer + ",computer")
    WinNT.............it's c:\windows\system32. On win 2003.

    Path problem, as mentioned befor.
    What happens if a big asteroid hits the Earth? Judging from realistic simulations involving a sledge hammer and a common laboratory frog, we can assume it will be pretty bad. - Dave Barry

  5. #5
    Senior Member
    Join Date
    Apr 2004
    Posts
    157
    To all of your replies, thanks! But it's not a path problem. This script works just fine under Win 2000, and not under Win 2003.
    WinNT: is part of the command, it's not actually the "windows" folder... (and I've tried it anyways, and get a syntax error instead...)

    I'm guessing they changed the commands around in Win2003... and I can't figure out what Win 2003 wants...

    To clarify the script a little:
    This script checks for the service "WebCT", if it's running. If not, it sends an email alert, and it also adds an Event Log, and then tries to start the "WebCT" service.
    If the "WebCT" service was running it simply just adds an Event Log stating so.
    The " strComputer = "." " line is used to define the local computer name, kinda like 127.0.0.1.

    This line:
    set objComputer = GetObject("WinNT://myDomain/" + strComputer + ",computer")

    Is there just to make this line work:
    set objNTService = objComputer.GetObject("service", strService)

    Which is the important line, so I can control the "WebCT" service. If I can replace "objComputer" line with something else to be able to execute the "objNTService" line, that would probably work too?!
    Feel free to run the script on your own computer, replacing the "WebCT" service with what ever else service you have running to test it out.. ?!

    Thanks again for all your help!

  6. #6
    Regal Making Handler
    Join Date
    Jun 2002
    Posts
    1,668
    Is . even a valid computer name under 2k3?
    The "." is local computer............. if the target was another computer it's name should be between the inverted commas
    What happens if a big asteroid hits the Earth? Judging from realistic simulations involving a sledge hammer and a common laboratory frog, we can assume it will be pretty bad. - Dave Barry

  7. #7
    Senior Member
    Join Date
    Apr 2004
    Posts
    157

    Exclamation

    Finally found the answer!
    Thanks for all your effort!

    Here is the solution for anyone interested:

    Replace this line,
    Code:
    strComputer = "."
    ...with this code:
    Code:
    Set objWshNet = CreateObject("WScript.Network")
    strComputer = objWshNet.ComputerName
    The comment I got about it is, strComputer="." isn't always supported using the WinNT provider under Win2003...
    Kinda strange but the replacement makes it work!

    Thanks again!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 Security News

     Patches

       Security Trends

         How-To

           Buying Guides