TCC-RT sendmail

ron

Aug 19, 2008
146
0
#1
So, using SENDMAIL with TCC-RT. I got it working by creating a .ini with pieces from my Take Command .ini file.

If later someone wants to use the batch file but not my SMTP credentials, how is that done? Without TCMD, there is no way to configure SMTP if all you have is TCC-RT - true?
 
#3
So, using SENDMAIL with TCC-RT. I got it working by creating a .ini with pieces from my Take Command .ini file.

If later someone wants to use the batch file but not my SMTP credentials, how is that done? Without TCMD, there is no way to configure SMTP if all you have is TCC-RT - true?
I don't believe there is any particular reason you couldn't create your own interface to allow users to configure these settings. For some BTMs I distribute within my own environment, I set some environment variables to sane defaults, then read a local INI which may override certain settings.

I omitted the initial variable sets at the top, and in my case I first run through a computer-wide INI and then second a user-specific INI, hence why %section% is a variable, but you could hardcode this instead. I also did a bit of sanity checking in the past, but I dropped that code as it was simply easier to pass the SMTP error off to the user if needed.

Once I finally have sane settings in varibles, I use a bunch of option // commands to set the settings in the current instance so that I can proceed with sendmail commands.

Code:
if %@len[%@iniread[%mailinipath,%section%,MailAddress]] gt 0 set MailAddress=%@iniread[%mailinipath,%section%,MailAddress]
if %@len[%@iniread[%mailinipath,%section%,MailPassword]] gt 0 set MailPassword=%@iniread[%mailinipath,%section%,MailPassword]
if %@len[%@iniread[%mailinipath,%section%,MailPort]] gt 0 set MailPort=%@iniread[%mailinipath,%section%,MailPort]
if %@len[%@iniread[%mailinipath,%section%,MailServer]] gt 0 set MailServer=%@iniread[%mailinipath,%section%,MailServer]
if %@len[%@iniread[%mailinipath,%section%,MailUser]] gt 0 set MailUser=%@iniread[%mailinipath,%section%,MailUser]
if %@len[%@iniread[%mailinipath,%section%,MailSSL]] gt 0 set MailSSL=%@iniread[%mailinipath,%section%,MailSSL]

option //MailAddress=%MailAddress%
option //MailPassword=%MailPassword%
option //MailPort=%MailPort%
option //MailServer=%MailServer%
option //MailUser=%MailUser%
option //MailSSL=%MailSSL%
You could either instruct users to complete an INI file manually, or prompt the user for settings and write the INI yourself. I don't know for certain whether any of this is limited in TCC-RT or not as I have not personally used TCC-RT at this time.
 
#4
... or let your script query the user for the necessary info (if not found in the INI file), setting it for the current instance with OPTION (and optionally saving it in the user's own INI file). Untested:

Code:
iff "%@iniread[%_ininame,4NT,MailServer]" == ""
    input Enter the name of your mail server: %%mailserver
    option /u //MailServer=%mailserver
endiff
Similarly for the other necessary info.
 
#5
So, using SENDMAIL with TCC-RT. I got it working by creating a .ini with pieces from my Take Command .ini file.

If later someone wants to use the batch file but not my SMTP credentials, how is that done? Without TCMD, there is no way to configure SMTP if all you have is TCC-RT - true?
This works for me:
Code:
@setlocal
@echo off
ver /r
iff %_tccrt eq 1 then
  option //MailServer=smtp-mail.outlook.com
  option //[email protected]
  option //MailPort=587
  option //[email protected]
  option //MailPassword=Password
  option //MailSSL=Yes
  sendmail /SSL=2 /v [email protected] "Hello from TCC-RT"
else
  echo Not running from TCC-RT
endiff
pause
endlocal
Joe
 

ron

Aug 19, 2008
146
0
#6
TCC-RT is intended to be configured by a system with Take Command or TCC.
Meaning I should do what I did - take the configuration pieces needed for my batch file and create an INI with those settings just for TCC-RT? Or is there some other method using TCC I've not found yet?

Thanks everyone else for the examples - I'd not thought about using OPTION - actually never used it before in a script. So TC disguises the email password in the .INI file. Using OPTION I suppose the email password must be not-disguised? Or do you use TC to derive a disguised password and plop that in the btm file?
 
Jul 29, 2016
36
1
#8
Use BATCOMP to compress and encrypt the batch file.

Joe
Realize though that there is a *BIG* weakness with using BATCOMP to encrypt batch files. If you use the LOG command to create a command log, it will log every command, including commands issued from batch files regardless if they've been compressed/encrypted or not. The encryption key must somehow be hard-coded into TCC, as TCC obviously needs to be able to decrypt the batch file (in memory) in order to read the commands that it needs to execute (and also to log in the command log if you've used the LOG command to turn that on).
 

rconn

Administrator
Staff member
May 14, 2008
10,614
97
#9
Realize though that there is a *BIG* weakness with using BATCOMP to encrypt batch files. If you use the LOG command to create a command log, it will log every command, including commands issued from batch files regardless if they've been compressed/encrypted or not.
Not true - recent versions of TCC & TCC-RT do *not* log commands if the batch file is compressed.