ตอน run script ไม่สามารถเเสดงภาษาไทยได้อะครับมันขึ้นเป็นภาษาต่างด้าว
อยากทราบว่าถ้าใส่ utf-8 ควรจะไปใส่บรรทัดไหนคับ
message="ภาษาไทยตรงนี้" ## Does not support multi line message.
title="Message from: Administrator"
def ecmd(CMD, OUT=False):
import ctypes
class disable_file_system_redirection:
_disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
_revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
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)
from subprocess import PIPE, Popen
with disable_file_system_redirection():
OBJ = Popen(CMD, shell = True, stdout = PIPE, stderr = PIPE)
out, err = OBJ.communicate()
ret=OBJ.returncode
return ret
def wfile(fp, c):
import os
with open(fp, 'w') as f:
f.write(c)
if os.path.isfile(fp):
return fp
return
import os
c1=r'''MsgBox "%s", 4096, "%s"'''%(message, title)
pm=os.path.join(os.environ['TEMP'], 'messagealert.vbs')
filem=wfile(pm, c1)
if ecmd('cscript "%s"'%filem)==0:
print 'The following message is sent the user.\n%s'%message
else:
print 'Error on sending message to the user'
os.remove(filem)