Re: help emailing this script

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Do you remember what I wrote in my previous note?

"Remember to pass two arguments to this subroutine
when calling it."

You appear to have ignored my reminder. Your subroutine
"WriteTextFile" requires two parameters, yet you call it with
none!

If this is not clear then have a look at your own subroutine:
sub WriteTextFile(txt, strTextFilePath)
' Procedure to write output to a text file
Dim objFSO,objTextFile
set objFSO = createobject("Scripting.FileSystemObject")
set objTextFile = objFSO.CreateTextFile(strTextFilePath)
objTextFile.Write(txt)
objTextFile.Close
SET objTextFile = nothing
end sub

Now ask yourself these questions:
a) What are the variables "txt" and "strTextFilePath"?
b) Where are they set in the main routine?
c) Where do you use them in the subroutine?


"arthursc" <arthursc@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C88567FB-2011-496A-BF7A-9EB47D1D1F35@xxxxxxxxxxxxxxxx
Sorry as Windows Script Host error message displays;

Script: C:\diskspace.vbs
Line: 8
Char: 1
Error: Wrong number of arguments or invalid property assignment:
'WrtiteTextFile'
Code: 800A01C2
Source: Microsoft VBScirpt runtime error

many thanks
colin.
"Pegasus (MVP)" wrote:

You need to realise that I cannot see your screen. I do not know
which of your lines is "Line 8" and unless you quote the error
message verbatim, I cannot comment on it.


"arthursc" <arthursc@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:523E6D10-B4B5-478E-BAAC-72E6632751CD@xxxxxxxxxxxxxxxx
Hi Pegasus,

Thanks for you imput on htis and most of all your patience. As
mentioned
not
a programmer but wotking on it. Below is the script I have now created
along
with you valuable input. I have two issues now;

script runs but no email sent. When script completes and echo's output
I
get
an erro located at Line 8 Char 1.

here is what I have created;

Option Explicit
const strComputer = "."
const strReport = "c:\diskspace.txt"
Dim objWMIService, objItem, colItems
Dim strDriveType, strDiskSize, txt

GetDiskParms
WriteTextFile
SendFile

Sub GetDiskParms
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from
Win32_LogicalDisk
WHERE DriveType=3")
txt = "Drive" & vbtab & "Size" & vbtab & "Used" & vbtab & "Free" &
vbtab
&
"Free(%)" & vbcrlf
DIM pctFreeSpace,strFreeSpace,strusedSpace
For Each objItem in colItems
pctFreeSpace = INT((objItem.FreeSpace / objItem.Size) * 1000)/10
strDiskSize = Int(objItem.Size /1073741824) & "Gb"
strFreeSpace = Int(objItem.FreeSpace /1073741824) & "Gb"
strUsedSpace = Int((objItem.Size-objItem.FreeSpace)/1073741824) &
"Gb"
txt = txt & objItem.Name & vbtab & strDiskSize & vbtab &
strUsedSpace &
vbTab & strFreeSpace & vbtab & pctFreeSpace & vbcrlf
Next
writeTextFile txt, strReport
wscript.echo "Report written to " & strReport & vbcrlf & vbcrlf & txt
end sub

sub WriteTextFile(txt, strTextFilePath)
' Procedure to write output to a text file
Dim objFSO,objTextFile
set objFSO = createobject("Scripting.FileSystemObject")
set objTextFile = objFSO.CreateTextFile(strTextFilePath)
objTextFile.Write(txt)
objTextFile.Close
SET objTextFile = nothing
end sub



Sub SendFile
schema = "http://schemas.microsoft.com/cdo/configuration/";

Set objEmail = CreateObject("CDO.Message")
With objEmail
.From = "SERVER@xxxxxx"
.To = "me@xxxxxx"
.Subject = "Test Mail"
.Textbody = "The quick brown fox " & Chr(10) & "jumps over the lazy
dog"
.AddAttachment "c:\diskspace.txt"
With .Configuration.Fields
.Item (schema & "sendusing") = 2
.Item (schema & "smtpserver") = "MY MAIL SERVER"
.Item (schema & "smtpserverport") = 25
End With
.Configuration.Fields.Update
.Send
End With
end sub

"Pegasus (MVP)" wrote:






.



Relevant Pages

  • Re: Detecting is hyperthreading is enabled with WMI?
    ... It is too bad that WMI does not give this info. ... have to be done to the script. ... Public Sub DisplayProcessorInfo ... dim ProcessorSet, Processor ...
    (microsoft.public.windowsxp.wmi)
  • Re: Collecting output generated via one spreadsheet into a new spreasheet
    ... A quick read of the script indicates that it makes no attempt to actually write out any of the information is has found. ... 'Call Output sub ... I would hazard a guess that if the output contains only the info associated with the last record from the input file, that you are failing to increment the row counter associated with the output spreadsheet after writing to it. ... Dim strUserName, objUserDomain, objGroup, objUser, strGroupList ...
    (microsoft.public.scripting.vbscript)
  • Re: Displaying text output in one external window
    ... application I use to control a script ... the log file and displays it in a ... > Dim oShell ... > Sub SaveScript() ...
    (microsoft.public.scripting.wsh)
  • Collecting output generated via one spreadsheet into a new spreasheet
    ... an excellent script written by Ralph Montgomery named NTUser.wsf for account ... Dim strUserName, objUserDomain, objGroup, objUser, strGroupList ... Dim objPwdExpiresTrue, objFlags, oPwdExpire, strPwdExpires ... Sub GetInfo() ...
    (microsoft.public.scripting.vbscript)
  • Re: Easy or Not? Adding spell-check to an existing InDesign VBScript
    ... You can use microsoft's word for spell-checking from script. ... Dim m_btnExitID ' as integer ... Dim bExitClick ' as boolean ... Sub oNMD_ButtonClick ...
    (microsoft.public.scripting.vbscript)