Solved

VBScript WScript error

Posted on 2011-09-29
2
771 Views
Last Modified: 2012-06-22
I originally had this code as a Sub within another VBScript and it functioned correctly.

But now I need it as a standalone script at get this runtime error:
Object doesn't support this property or method: WScript.Arguments

So I have left something out to be able to correctly receive the command line arguments.  Can anyone please point out my error(s)?
''Sub SendIt(ByVal msgType, ByVal strSubject, ByVal strMessage)

Dim myShell
Dim myProcEnv
Set myShell = CreateObject("WScript.Shell")
 
Dim msgType     :               WScript.Arguments(0)
Dim strSubject  :               WScript.Arguments(1)
Dim strMessage  :               WScript.Arguments(2)
    Dim jm  : jm=False
               
               
    If (ucase(GetXMLText("Email\Enabled"))="TRUE") and GetXMLText("Email\SMTP")<> "" Then
        SetXMLText "Email\Enabled" , "True"
        jm=True
    Else
        SetXMLText "Email\Enabled" , "False"
        jm=False
        'Exit Sub
                                Response.End
    End If
 
    Dim Recipients : Recipients=0
        on error resume next
 
    Dim xmlDoc      ' Main XML document
    Set xmlDoc = GLOBAL_GetXMLDoc
 
    Dim mainNode    ' Main XML document
 
    Recipients = xmlDoc.getElementsByTagName("Email").item(0).getElementsByTagName("Recipient").Length
 
    If Recipients = 0 Then
        On Error Goto 0
        'Exit Sub
         Response.End
    End If
 
Dim fullMessage : fullMessage = ""
    fullMessage = fullMessage & GetXMLText("Email\EmailPrefix") & vbCrlf & vbCrlf
 
    Dim sType
    Select Case ucase(msgType)
        Case "SUCCESS"      : fullMessage = fullMessage & GetXMLText("Email\EmailSuccessMessage")  : sType = "Success"
        Case "FAILURE"      : fullMessage = fullMessage & GetXMLText("Email\EmailFailureMessage")  : sType = "Failure"
        Case "STATUS"       : fullMessage = fullMessage & GetXMLText("Email\EmailStatusMessage")   : sType = "Status"
        Case Else           : fullMessage = fullMessage & "<Invalid Message Type>"
    End Select
 
    fullMessage = fullMessage & vbCrlf & vbCrlf & strMessage & vbCrlf & vbCrlf
 
    fullMessage = fullMessage & GetXMLText("Defaults\EmailSuffix") & vbCrlf & vbCrlf
 
    Dim jmail
 
    If jm Then
         Set jmail = CreateObject("JMail.Message")
         jmail.silent=true
         jmail.logging=true
 
         jmail.from         = xmlDoc.getElementsByTagName("Email").item(0).getElementsByTagName("From").item(rCtr).getattribute("Address")
         jmail.fromname     = xmlDoc.getElementsByTagName("Email").item(0).getElementsByTagName("From").item(rCtr).getattribute("name")
    End If
 
' for each email address in MAIN DEFAULTS
' for each email address in EMAIL.RECIPIENT
    Dim rCtr : rCtr=0
    Do While rCtr < Recipients
        If xmlDoc.getElementsByTagName("Email").item(0).getElementsByTagName("Recipient").item(rCtr).getattribute(sType)="True" Then
            If jm Then     jmail.AddRecipient xmlDoc.getElementsByTagName("Email").item(0).getElementsByTagName("Recipient").item(rCtr).getattribute("Address")
        End If
        rCtr = rCtr + 1
    Loop
 
    If jm Then
        jmail.subject      = strSubject
        jmail.body         = fullMessage
        If objFSO.FileExists(replog) then
            jmail.AddAttachment  replog
        End If
        jmail.send( GetXMLText("Email\SMTP") )
    End If
 
' Clean up...
    Set jmail=Nothing
'''End Sub

Open in new window

0
Comment
Question by:kkbenj
2 Comments
 
LVL 8

Accepted Solution

by:
jawa29 earned 500 total points
ID: 36815009
Hi

All you need to do is chnage it to this
Dim msgType : msgType = WScript.Arguments(0)
Dim strSubject : strSubject = WScript.Arguments(1)
Dim strMessage : strMessage = WScript.Arguments(2)

Jawa29
0
 

Author Closing Comment

by:kkbenj
ID: 36815104
an oversight for sure.

Thanks for the clarity.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now