Skip to content

Instantly share code, notes, and snippets.

@yamadaaaaaaa
Created June 25, 2020 08:59
Show Gist options
  • Save yamadaaaaaaa/a5b393b6cb13e69792b080024030104c to your computer and use it in GitHub Desktop.
Save yamadaaaaaaa/a5b393b6cb13e69792b080024030104c to your computer and use it in GitHub Desktop.
maya_escapeMalware.py
import stat
import os
import re
import ctypes
from ctypes.wintypes import MAX_PATH
def maya_escapeMalware():
# set read only animImportExport.pres.mel
adkPath = r'C:\Program Files\Autodesk'
if not os.path.exists(adkPath):return
for aaa in os.listdir(adkPath):
if not re.search('Maya(?P<n>\d+)',aaa):continue
dirA = os.path.join(adkPath,aaa,'resources','l10n')
if not os.path.exists(dirA):continue
for bbb in os.listdir(dirA):
path_aie = os.path.join(dirA,bbb,'plug-ins','animImportExport.pres.mel')
if not os.path.exists(path_aie):continue
if os.access(path_aie, os.W_OK):
os.chmod(path_aie, stat.S_IREAD)
# set read only userSetup.mel
home = os.path.join(os.getenv("HOMEDRIVE"),os.getenv("HOMEPATH"),"Documents")
dll = ctypes.windll.shell32
buf = ctypes.create_unicode_buffer(MAX_PATH + 1)
if dll.SHGetSpecialFolderPathW(None, buf, 0x0005, False):
home = buf.value
path_usp = os.path.join(home,'maya','scripts','userSetup.mel')
# Just in case
#melText = '{' + os.linesep + \
# 'global int $autoUpdateAttrEd_aoto_int;' + os.linesep + \
# '$autoUpdateAttrEd_aoto_int = -1;' + os.linesep + \
# '}'
melText = """{
global int $autoUpdateAttrEd_aoto_int;
$autoUpdateAttrEd_aoto_int = -1;
}"""
if not os.path.exists(path_usp):
with open(path_usp, "w") as f:
f.write(melText)
os.chmod(path_usp, stat.S_IREAD)
else:
with open(path_usp, "r") as f:
s = f.read()
s += os.linesep + melText
if not os.access(path_aie, os.W_OK):
os.chmod(path_usp, stat.S_IWRITE)
with open(path_usp, "w") as f:
f.write(s)
os.chmod(path_usp, stat.S_IREAD)
# EOF Just in case
maya_escapeMalware()
@yamadaaaaaaa
Copy link
Author

yamadaaaaaaa commented Jun 25, 2020

runBatch.bat

echo off
set python="Python27\python.exe"
set py="maya_escapeMalware.py"
powershell start-process %python% %py% -verb runas -wait
echo "complete..."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment