#41175 - 2003-06-06 08:59 PM
call out a VBscript from a kixtart script
|
ktodi
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
   
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
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
for a 2nd pass at it....
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
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
|
|
|
|
#41180 - 2003-06-06 10:44 PM
Re: call out a VBscript from a kixtart script
|
ktodi
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
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
|
|
Top
|
|
|
|
#41182 - 2003-06-06 10:51 PM
Re: call out a VBscript from a kixtart script
|
Kdyer
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
|
|
Top
|
|
|
|
#41184 - 2003-06-06 10:58 PM
Re: call out a VBscript from a kixtart script
|
Shawn
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
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
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
|
|
Top
|
|
|
|
#41187 - 2003-06-07 04:02 AM
Re: call out a VBscript from a kixtart script
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Look above..
Your code (VBScript) -
objEmail..
Converts to (KiXtart) -
$objEmail..
For example..
Kent
|
|
Top
|
|
|
|
#41189 - 2003-06-09 08:43 PM
Re: call out a VBscript from a kixtart script
|
ktodi
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
|
|
|
|
#41191 - 2003-06-09 10:26 PM
Re: call out a VBscript from a kixtart script
|
Chris S.
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
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
|
|
Top
|
|
|
|
#41193 - 2003-06-10 12:33 AM
Re: call out a VBscript from a kixtart script
|
ktodi
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
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 386 anonymous users online.
|
|
|