01.
message=
"ภาษาไทยตรงนี้"
## Does not support multi line message.
02.
title=
"Message from: Administrator"
03.
def ecmd(CMD, OUT=False):
04.
import ctypes
05.
class disable_file_system_redirection:
06.
_disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
07.
_revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
08.
def __enter__(self):
09.
self.old_value = ctypes.c_long()
10.
self.success = self._disable(ctypes.byref(self.old_value))
11.
def __exit__(self, type, value, traceback):
12.
if
self.success:
13.
self._revert(self.old_value)
14.
from subprocess import PIPE, Popen
15.
with
disable_file_system_redirection():
16.
OBJ = Popen(CMD, shell = True, stdout = PIPE, stderr = PIPE)
17.
out, err = OBJ.communicate()
18.
ret=OBJ.returncode
19.
return
ret
20.
21.
def wfile(fp, c):
22.
import os
23.
with
open(fp,
'w'
) as f:
24.
f.write(c)
25.
if
os.path.isfile(fp):
26.
return
fp
27.
return
28.
29.
import os
30.
c1=r
''
'MsgBox "%s", 4096, "%s"'
''
%(message, title)
31.
pm=os.path.join(os.environ[
'TEMP'
],
'messagealert.vbs'
)
32.
filem=wfile(pm, c1)
33.
if
ecmd(
'cscript "%s"'
%filem)==0:
34.
print
'The following message is sent the user.\n%s'
%message
35.
else
:
36.
print
'Error on sending message to the user'
37.
os.remove(filem)