I need the following script Run a batch file appended

BAT=r’’’
C:\SmartNetworks\Tools\myfile.bat
‘’’

import os
import sys
import platform
import subprocess
import ctypes

class disable_file_system_redirection:
_disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirect ion
_revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirecti on
def enter(self):
self.old_value = ctypes.c_long()
self.success = self._disable(ctypes.byref(self.old_value))
def exit(self, type, value, traceback):
if self.success:
self._revert(self.old_value)

path=“C:\SmartNetworks\Tools\myfiletemp.bat”
with open(path,“w”) as f:
f.write(BAT)
try:
with disable_file_system_redirection():
print “Excuting Bat File”
process = subprocess.Popen([path],stdout=subprocess.PIPE)
stdout = process.communicate()[0]
print “---------------------------”
print stdout

except:
print “Excuting Bat File”
process = subprocess.Popen([path],stdout=subprocess.PIPE)
stdout = process.communicate()[0]
print “---------------------------”
print stdout

if os.path.exists(path):
try:
os.remove(path)
except:
pass


That script creates the following output in the log

Executing Bat File

C:\SmartNetworks\Tools\CheckIn Spectre.bat WARNING:
The system is VULNERABLE to Meltdown and/or Spectre. WARNING:
This system does NOT have the firmware/microcode patch installed to be able to address Spectre.
"Spectre Checker Result: " 56


can you append this script so that it sends this info in an email

Hello @smartnetworks

Yes, we will supply the script link with the modification you have said.
Thank you.

Hi @smartnetworks ,

Refer the attached JSON file for sending an email,

Note:

Edit Parameters:

emailto=[‘xxx@gmail.com’] # Provide a To email address where the report needs to be sent. You can also provide any number of To email address For example: [‘yyy@gmail.com’, ‘zz@gmail.com’]

sendmail=1 ## [1 sends mail or 0 does not send mail] if sendmail=1 then user have to set the required information to send out an email from the code.

Let us know your feedback,

Thank you

20180822-mail_bat_execution.json (5.08 KB)