Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 26th, 2007, 09:05 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default Creating Job with VBScript in it Fails

I am not sure if I am so exhausted, that I don't find anything wrong with this though it runs fine from command prompt using cscript, still it is playing with my time by not creating the job giving this error.
Error 14277: The command script does not destroy all the objects that it creates. Revise the command script. The job was not saved.
I have similar other steps with vbscripts working fine. But still this kills my time. Can anyone see if I am doing something wrong with this code.

This script basically starts an application and verifies if its child processes are running fine, else sends out an email with error.

The ones in BLUE are the objects created, and the ones BLUE are the objects destroyed.
Code:
Dim StrComputer, StrSql, Con, ConStr, RS, objWMIService, colProcessList, iRow, iCol, ArrRowSet
Dim Wshshell, StrCmd, RetCode
StrComputer = "."
Set Con = CreateObject("adodb.connection")
ConStr = "Provider=sqloledb;Data Source=localhost;Initial Catalog=SOMEDB;User Id=xyz;Password=xyz;"
Con.Open ConStr
StrSql = "SELECT AppName FROM mytable ORDER BY StartupSeqID"
Set RS = Con.Execute(StrSql)
ArrRowSet = RS.GetRows()
Set Con = Nothing
Set RS = Nothing

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & StrComputer & "\root\cimv2")
Set Wshshell = WScript.CreateObject("wscript.shell")
StrCmd = """C:\Program Files\someapp.exe"""
RetCode = Wshshell.run(StrCmd, 1, FALSE)
WScript.Sleep(5000)
If RetCode = 0 Then
'Verify the relevant child processes of this app
    For iRow = LBound(ArrRowSet, 2) To UBound(ArrRowSet, 2) 
        For iCol = LBound(ArrRowSet, 1) To UBound(ArrRowSet, 1)
            Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = '" & ArrRowSet(iCol, iRow) & "'")
            For Each objProcess in colProcessList
                If UCase(objProcess.Name) <> UCase(ArrRowSet(iCol, iRow)) Then 
                    SendErrorMail ArrRowSet(iCol, iRow)
                End If
            Next
            Set colProcessList = Nothing
        Next
    Next
End If

Set objWMIService = Nothing
Set Wshshell = Nothing

Function SendErrorMail (strAppName)
    Dim objNet, objCDOMail, strBody, strTo, strSubject, strCC, strComputerName
    strTo =  "me@myid.com"
    Set objNet = CreateObject("WScript.NetWork")
    strComputerName = objNet.ComputerName
    Set objNet = Nothing
    strSubject = "some subject"
    strBody =  strBody & "some body message"
    Set objCDOMail = CreateObject("CDO.Message")
        objCDOMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        objCDOMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
        objCDOMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
        objCDOMail.Configuration.Fields.Update 
        objCDOMail.From    = strComputerName
        objCDOMail.To      = strTo
        objCDOMail.CC      = strCC
        objCDOMail.Bcc     = strBcc
        objCDOMail.Subject = strSubject
        objCDOMail.TextBody    = strBody
        objCDOMail.Send
    Set objCDOMail = Nothing
End Function
Cheers.

_________________________
- Vijay G
Strive for Perfection
__________________
- Vijay G
Reply With Quote
  #2 (permalink)  
Old April 27th, 2007, 02:56 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Some sleep last night gave me some energy to get through this. I was writing a function/sub there for the email code. When I removed the function and put that code within the main code it worked.

Anyways, thanks for your time in reading this.
Cheers.

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i get a job as a programmer while in H.S.? iceman90289 C# 2005 10 March 27th, 2008 08:43 PM
Job Fails - trying to insert into remote machine happygv SQL Server 2000 0 March 8th, 2007 10:03 AM
job for experts g_tufat Need help with your homework? 0 July 3rd, 2006 05:49 PM
Job fails & need to use domain\user acct to run kiwikencox SQL Server 2000 1 October 17th, 2005 09:30 PM
DB backup Job fails within a second or two happygv SQL Server 2000 6 October 16th, 2004 01:21 PM



All times are GMT -4. The time now is 06:24 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.