Page 1 of 2 12>
Topic Options
#41175 - 2003-06-06 08:59 PM call out a VBscript from a kixtart script
ktodi Offline
Getting the hang of it

Registered: 2002-03-29
Posts: 60
Hi, I currently run a kixtart script that checks to see if a file share exists. If the file share does not exist I have it configured to send my computer a message. To improve this system I want to enable my script to send email. To do this I wrote a VBscript that will send me a message. The problem I am having is that I use the command RUN "test.vbs" and nothing happens the script is in the netlogon share of all domain controllers. Do I have to use UNC path? Is the run command the wrong this to use do I need to use shell or comspec? What is the best way to call out the vbscript or is there a beter way to do what I want?
Top
#41176 - 2003-06-06 09:51 PM Re: call out a VBscript from a kixtart script
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
For a first pass at this, would tend to try this:

code:
Break On

?"Calling VBS ..."

SHELL "%COMSPEC% /C CSCRIPT //NOLOGO C:\TEST.VBS"

?"Done ..."

Exit 1


Top
#41177 - 2003-06-06 10:02 PM Re: call out a VBscript from a kixtart script
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
for a 2nd pass at it.... [Big Grin]

why not use kix to send the email??

Top
#41178 - 2003-06-06 10:18 PM Re: call out a VBscript from a kixtart script
ktodi Offline
Getting the hang of it

Registered: 2002-03-29
Posts: 60
I would use kix to send the emial but I have not found an option that would work without having outlook installed on the machine running the script.
Top
#41179 - 2003-06-06 10:29 PM Re: call out a VBscript from a kixtart script
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
hmmm, i can't help but think that whatever VBS can do, Kixtart can do, maybe even better. Whats so unique about that VBS script ?
Top
#41180 - 2003-06-06 10:44 PM Re: call out a VBscript from a kixtart script
ktodi Offline
Getting the hang of it

Registered: 2002-03-29
Posts: 60
I thought the same thing until this email thing came up. here is the vbscript i run:

Set objNetwork = WScript.CreateObject("WScript.Network")
UserName = objNetwork.UserName
CompName = objNetwork.Computername
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "scripterror@mydomain.com"
objEmail.To = "myname@mydomain.com"
objEmail.Subject = "subject"
objEmail.Textbody = _
"The User: " & UserName & " on Worksation: " & CompName & " could not get to subject"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"mail.mydomain.com"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send

Top
#41181 - 2003-06-06 10:50 PM Re: call out a VBscript from a kixtart script
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
I think we talk about CDO, Outlook, Postie, BLAT, etc. here -
How do I send e-mail from KiXtart- (SMTP)

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#41182 - 2003-06-06 10:51 PM Re: call out a VBscript from a kixtart script
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Here you go (untested)..

code:
$objNetwork = WScript.CreateObject("WScript.Network")
$UserName = $objNetwork.UserName
$CompName = $objNetwork.Computername
$objEmail = CreateObject("CDO.Message")
$objEmail.From = "scripterror@mydomain.com"
$objEmail.To = "myname@mydomain.com"
$objEmail.Subject = "subject"
$objEmail.Textbody = "The User: " + $UserName + " on Worksation: " + $CompName + " could not get to subject"
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.mydomain.com"
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
$objEmail.Configuration.Fields.Update
$objEmail.Send

HTH,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#41183 - 2003-06-06 10:51 PM Re: call out a VBscript from a kixtart script
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
dont have CDO here, but is this the line that wont work (in kix) ?

objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

-Shawn

[ 06. June 2003, 22:53: Message edited by: Shawn ]

Top
#41184 - 2003-06-06 10:58 PM Re: call out a VBscript from a kixtart script
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Nice kent (your fast) ... if Kents example doesn't work right off the bat, try appending the "value" property to those settings, example:

code:
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing").Value = 2


Top
#41185 - 2003-06-07 12:58 AM Re: call out a VBscript from a kixtart script
ktodi Offline
Getting the hang of it

Registered: 2002-03-29
Posts: 60
Where is kent's example?
Top
#41186 - 2003-06-07 01:01 AM Re: call out a VBscript from a kixtart script
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
kent = kdyer
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#41187 - 2003-06-07 04:02 AM Re: call out a VBscript from a kixtart script
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Look above.. [Wink]

Your code (VBScript) -

objEmail..

Converts to (KiXtart) -

$objEmail..

For example..

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#41188 - 2003-06-07 04:19 AM Re: call out a VBscript from a kixtart script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
actually, it doesn't look like example.
it looks like totally converted code.

one might notice with first look at the codes that kixtart code has one benefit over vbscript:
it's always shorter [Big Grin]

anyway, scroll to kdyer's post of "posted 06. June 2003 22:51"

and test the code.
then, if you have trouble with it, post which kinda...
_________________________
!

download KiXnet

Top
#41189 - 2003-06-09 08:43 PM Re: call out a VBscript from a kixtart script
ktodi Offline
Getting the hang of it

Registered: 2002-03-29
Posts: 60
Putting the .Value before every "value" fixed those errors. I am still not recieving the email though and when I run the script when it exectutes the converted vbscript code I see on the screen the words WScript.Network should i put the $ symbol in from of that staement too. Kixtart is seeing the "" and outs that info on the screen.
Top
#41190 - 2003-06-09 10:10 PM Re: call out a VBscript from a kixtart script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
there is problem in code by kdyer.
the line of:
$objNetwork = WScript.CreateObject("WScript.Network")

should actually be:
$objNetwork = CreateObject("WScript.Network")
_________________________
!

download KiXnet

Top
#41191 - 2003-06-09 10:26 PM Re: call out a VBscript from a kixtart script
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Actually, these lines can be omitted altogether...

code:
$objNetwork = WScript.CreateObject("WScript.Network")
$UserName = $objNetwork.UserName
$CompName = $objNetwork.Computername

$UserName can be replaced with @USERID and $CompName can be replaced with @WKSTA in the remaining lines of code.

Top
#41192 - 2003-06-09 10:36 PM Re: call out a VBscript from a kixtart script
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
With corrections -
code:
$objEmail = CreateObject("CDO.Message")
$objEmail.From = "scripterror@mydomain.com"
$objEmail.To = "myname@mydomain.com"
$objEmail.Subject = "subject"
$objEmail.Textbody = "The User: " + @userid + " on Worksation: " + @wksta + " could not get to subject"
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.mydomain.com"
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
$objEmail.Configuration.Fields.Update
$objEmail.Send

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#41193 - 2003-06-10 12:33 AM Re: call out a VBscript from a kixtart script
ktodi Offline
Getting the hang of it

Registered: 2002-03-29
Posts: 60
I used your emaple for my script, but put the .Value statement back in as referenced above. I now get the textbody message showing up in the script and no email is being received still.
Top
#41194 - 2003-06-10 12:43 AM Re: call out a VBscript from a kixtart script
ktodi Offline
Getting the hang of it

Registered: 2002-03-29
Posts: 60
In my last post I mentioned the script was writn the body to the screen that was my error and I fuixed it. Now nothing appears on the screen when I run the script and I am still not receiving the e-mail.
Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 504 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.078 seconds in which 0.03 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org