issue i am having

does anyone know how to fix this in 3ds max? i tried to install a script but it didn't work, now am getting only this
[IMG]http://i779.photobucket.com/albums/yy80/skurl/Capture1_zpseeaa6c71.jpg[/IMG]
try
(
N3D_theTimer.stop()
-- Remove Event Handler
dotnet.removeAllEventHandlers N3D_theTimer
-- Dispose Timerf
N3D_theTimer.Dispose()
)
catch()

---------------------------------------------------------------------------------------------------
-- DotNetProcessor by biddle
-- http://forums.cgsociety.org/showpost.php?p=7010193&postcount=3
---------------------------------------------------------------------------------------------------

fn CreateDotNetProcessor =
(
if dotnet.GetType "DotNetProcessor" == undefined do
(
format "Constructing .NET Processor...\n"
-- If layout of this text looks ragged, press ctrl-F11 to switch to a monospaced font...
sb = ""
sb +=" using System; \n"
sb +=" using System.Text; \n"
sb +=" using System.Diagnostics; \n"
sb +=" \n"
sb +=" class DotNetProcessor \n"
sb +=" { \n"
sb +=" \n"
sb +=" private static StringBuilder stdOut = null; \n"
sb +=" private static StringBuilder stdErr = null; \n"
sb +=" \n"
sb +=" public String Output() { return stdOut == null ? \"\" : stdOut.ToString(); } \n"
sb +=" public String Errors() { return stdErr == null ? \"\" : stdErr.ToString(); } \n"
sb +=" \n"
sb +=" public void Execute(String filename, String args, String stdinbuff) \n"
sb +=" { \n"
sb +=" Process p = new System.Diagnostics.Process(); \n"
sb +=" \n"
sb +=" stdErr = new StringBuilder(); \n"
sb +=" stdOut = new StringBuilder(); \n"
sb +=" \n"
sb +=" p.EnableRaisingEvents = true; \n"
sb +=" p.StartInfo.FileName = filename; \n"
sb +=" p.StartInfo.Arguments = args; \n"
sb +=" p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden ; \n"
sb +=" p.StartInfo.UseShellExecute = false; \n"
sb +=" p.StartInfo.RedirectStandardOutput = true; \n"
sb +=" p.StartInfo.RedirectStandardError = true; \n"
sb +=" p.StartInfo.RedirectStandardInput = stdinbuff.Length > 0; \n"
sb +=" \n"
sb +=" p.StartInfo.CreateNoWindow = true; \n"
sb +=" \n"
sb +=" p.OutputDataReceived += new DataReceivedEventHandler(OutputHandler); \n"
sb +=" p.ErrorDataReceived += new DataReceivedEventHandler(ErrorHandler); \n"
sb +=" \n"
sb +=" p.Start(); \n"
sb +=" \n"
sb +=" if (stdinbuff.Length > 0) \n"
sb +=" { \n"
sb +=" p.StandardInput.Write(stdinbuff); \n"
sb +=" p.StandardInput.Close(); \n"
sb +=" } \n"
sb +=" \n"
sb +=" stdErr = new StringBuilder(); \n"
sb +=" stdOut = new StringBuilder(); \n"
sb +=" \n"
sb +=" p.BeginOutputReadLine(); \n"
sb +=" p.BeginErrorReadLine(); \n"
sb +=" \n"
sb +=" p.WaitForExit(); \n"
sb +=" p.Close(); \n"
sb +=" } \n"
sb +=" \n"
sb +=" private static void OutputHandler(object sendingProcess, DataReceivedEventArgs d) \n"
sb +=" { \n"
sb +=" if (!String.IsNullOrEmpty(d.Data)) stdOut.Append(d.Data + \"\\n\"); \n"
sb +=" } \n"
sb +=" \n"
sb +=" private static void ErrorHandler(object sendingProcess, DataReceivedEventArgs d) \n"
sb +=" { \n"
sb +=" if (!String.IsNullOrEmpty(d.Data)) stdErr.Append(d.Data + \"\\n\"); \n"
sb +=" } \n"
sb +=" } \n"

csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"

compilerParams.ReferencedAssemblies.Add("System.dll");

compilerParams.GenerateInMemory = true
compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(sb)

if (compilerResults.Errors.Count > 0 ) then
(
errs = stringstream ""
for i = 0 to (compilerResults.Errors.Count-1) do
(
err = compilerResults.Errors.Item[i]
format "Error:% Line:% Column:% %\n" err.ErrorNumber err.Line \
err.Column err.ErrorText to:errs
)
MessageBox (errs as string) title: "Errors encountered while compiling C# code"
format "%\n" errs
return undefined
)
)
dotnetobject "DotNetProcessor"
)

---------------------------------------------------------------------------------------------------
-- HiddenDotNetCommand
---------------------------------------------------------------------------------------------------

fn HiddenDotNetCommand exe args input=
(
dnp = CreateDotNetProcessor()
dnp.execute exe args input
--format "output:\n%" (dnp.output())
--format "errors:\n%" (dnp.errors())
)

fn KillAndLaunchDialog theRollout kill launch=
(
if kill do try ( DestroyDialog theRollout; ) catch();
if launch do createDialog theRollout
)

KillAndLaunchDialog MaxScriptManager true false
KillAndLaunchDialog install_mzp_warning true false
KillAndLaunchDialog MSM_settings true false
KillAndLaunchDialog MSM_about true false
KillAndLaunchDialog clipboard_to_ms_rollout true false
KillAndLaunchDialog MSM_Repository_Manager true false
KillAndLaunchDialog MSM_devtools true false

b = pathConfig.removePathLeaf(pathConfig.removePathLeaf(pathConfig.removePathLeaf (pathConfig.removePathLeaf (GetDir #userScripts)))) -- ="C:\Users\Norman\AppData\Local\Autodesk\3dsMax"
c = filterString (symbolicPaths.getPathValue "$userscripts") "\\" --splits the path to get certain names
d = (c[c.count - 1]) --this is "enu
s1 = (c[c.count - 2])
s2 = " "
s3 = "_"
d_f = substituteString (c[c.count - 2]) " " "_"--This is "2011 -32bit"
Design3dsMax = (c[c.count - 3])

makeDir "$userscripts\\MaxScriptManager\\"
for f in getFiles "$userscripts\\MaxScriptManager\\*.ms" do deleteFile f
for f in getFiles "$userscripts\\MaxScriptManager\\*.exe" do deleteFile f
for f in getFiles "$userscripts\\MaxScriptManager\\*.mcr" do deleteFile f
makeDir "$userscripts\\MaxScriptManager\\Inbox\\"
makeDir "$userscripts\\MaxScriptManager\\INI_Auto\\"
makeDir "$userscripts\\MaxScriptManager\\INI_Manual\\"
makeDir "$userscripts\\MaxScriptManager\\Repositories\\"
makeDir "$userscripts\\MaxScriptManager\\Repositories\\Downloaded\\"
makeDir "$userscripts\\MaxScriptManager\\Resources\\"
makeDir "$userscripts\\MaxScriptManager\\Resources\\Dialog\\"
for f in getFiles "$userscripts\\MaxScriptManager\\Resources\\Dialog\\*.*" do deleteFile f
makeDir "$userscripts\\MaxScriptManager\\Resources\\Listview\\"
for f in getFiles "$userscripts\\MaxScriptManager\\Resources\\Listview\\*.*" do deleteFile f
makeDir "$userscripts\\MaxScriptManager\\Resources\\MainToolbar Icon\\"
for f in getFiles "$userscripts\\MaxScriptManager\\Resources\\MainToolbar Icon\\*.*" do deleteFile f
makeDir "$userscripts\\MaxScriptManager\\Resources\\Manual Install\\"
for f in getFiles "$userscripts\\MaxScriptManager\\Resources\\Manual Install\\*.*" do deleteFile f
makeDir "$userscripts\\MaxScriptManager\\Resources\\RC\\"
for f in getFiles "$userscripts\\MaxScriptManager\\Resources\\RC\\*.*" do deleteFile f
makeDir "$userscripts\\MaxScriptManager\\SCRIPT_Auto\\"
makeDir "$userscripts\\MaxScriptManager\\SCRIPT_Manual\\"
makeDir "$userscripts\\MaxScriptManager\\WebsiteSources\\"

makeDir "$userscripts\\MaxScriptManager\\DevTools\\Repository Manager\\Temp\\"
makeDir "$userscripts\\MaxScriptManager\\DevTools\\Repository Manager\\Output\\"
makeDir "$userscripts\\MaxScriptManager\\DevTools\\Watermark\\Temp\\"
for f in getFiles "$userscripts\\MaxScriptManager\\DevTools\\*.*" do deleteFile f

for f in getFiles "$userscripts\\MaxScriptManager_TEMP\\*.*" do
(
renameFile f ("$userscripts\\MaxScriptManager\\" + getFileNameFile f + getFileNameType f)
)

for f in getFiles "$userscripts\\MaxScriptManager_TEMP\\Resources\\*.*" do
(
renameFile f ("$userscripts\\MaxScriptManager\\Resources\\" + getFileNameFile f + getFileNameType f)
)

for f in getFiles "$userscripts\\MaxScriptManager_TEMP\\Resources\\Dialog\\*.*" do
(
renameFile f ("$userscripts\\MaxScriptManager\\Resources\\Dialog\\" + getFileNameFile f + getFileNameType f)
)

for f in getFiles "$userscripts\\MaxScriptManager_TEMP\\Resources\\Listview\\*.*" do
(
renameFile f ("$userscripts\\MaxScriptManager\\Resources\\Listview\\" + getFileNameFile f + getFileNameType f)
)

for f in getFiles "$userscripts\\MaxScriptManager_TEMP\\Resources\\MainToolbar Icon\\*.*" do
(
renameFile f ("$userscripts\\MaxScriptManager\\Resources\\MainToolbar Icon\\" + getFileNameFile f + getFileNameType f)
)

for f in getFiles "$userscripts\\MaxScriptManager_TEMP\\Resources\\Manual Install\\*.*" do
(
renameFile f ("$userscripts\\MaxScriptManager\\Resources\\Manual Install\\" + getFileNameFile f + getFileNameType f)
)

for f in getFiles "$userscripts\\MaxScriptManager_TEMP\\Resources\\RC\\*.*" do
(
renameFile f ("$userscripts\\MaxScriptManager\\Resources\\RC\\" + getFileNameFile f + getFileNameType f)
)

for f in getFiles "$userscripts\\MaxScriptManager_TEMP\\DevTools\\*.*" do
(
renameFile f ("$userscripts\\MaxScriptManager\\DevTools\\" + getFileNameFile f + getFileNameType f)
)

makeDir (b + "\\MaxScriptManager\\")
for f in getFiles "$userscripts\\MaxScriptManager_TEMP\\MaxScriptManager\\*.*" do
(
deleteFile (b + "\\MaxScriptManager\\" + getFileNameFile f + getFileNameType f)
renameFile f (b + "\\MaxScriptManager\\" + getFileNameFile f + getFileNameType f)
)

--AVGuard Extension for 3dsMax 9
plugins_folder = (pathConfig.removePathLeaf("$plugins") + "\\plugins\\")
ver = maxversion()
ver2 = ver[1]
if ver2 < 9000 do
(
--Is it already installed?
if doesFileExist (plugins_folder + "\\avg_dlx90.dlx") == false do
(
messagebox "AVGuard has been installed. Restart 3dsMax and install MaxScriptManager again."
--No!
--Is it 32bit or 64bit?
if doesFileExist "$max\\max32.task" == true then
(
--It's 32 bit!
renameFile "$userscripts\\MaxScriptManager_TEMP\\AVG\\x86\\avg_dlx90.dlx" (plugins_folder + "\\avg_dlx90.dlx")
)
else
(
--It's 64 bit!
renameFile "$userscripts\\MaxScriptManager_TEMP\\AVG\\x64\\avg_dlx90.dlx" (plugins_folder + "\\avg_dlx90.dlx")
)
)
)

HiddenDotNetCommand "cmd.exe" ("/K rmDir " + "\"" + (getDir #userscripts + "\\MaxScriptManager_TEMP\\") + "\"" + " /s /q") ""

--Is 3dsMax still there?
for f in getFiles (b + "\\MaxScriptManager\\*MaxPath.txt") do
(
inputData =#()
g = openfile f
while (not eof g) do
(
append inputData (readLine g)
)
close g

for n in inputData do
(
if doesFileExist n == true then
(
--Yes! This means ScriptManager is also there, otherwise, the _MaxPath file wouldn't be there in the first place.
)
else
(
--No! Delete _MaxPath and _DownloadTemp
filename = getFileNameFile f
filteredstring = filterString filename "_"
if doesFileExist (b + "\\MaxScriptManager\\" + (filteredstring[1] + "_" + filteredstring[2] + "_" + filteredstring[3]) + "_DownloadTemp.txt") do
(
deleteFile (b + "\\MaxScriptManager\\" + (filteredstring[1] + "_" + filteredstring[2] + "_" + filteredstring[3]) + "_DownloadTemp.txt")
)
deleteFile f
)
)
)

--Right now we got rid of all the left overs. Now we need to, find if _MaxPath for this 3dsmax version is already there, delete it and create a new one.

theMaxPathFile = b + "\\MaxScriptManager\\" + Design3dsMax + "_" + d_f + "_MaxPath.txt"
theInboxFile = b + "\\MaxScriptManager\\" + Design3dsMax + "_" + d_f + "_DownloadTemp.txt"

if doesFileExist theMaxPathFile do deleteFile theMaxPathFile -- delete old tmp file if exist
f = createFile theMaxPathFile
format (getdir #maxroot + "3dsmax.exe") to:f
flush f
close f

if doesFileExist theInboxFile do deleteFile theInboxFile -- delete old tmp file if exist
f = createFile theInboxFile
format (substituteString (getdir #userscripts + "\\MaxScriptManager\\Inbox\\") "\\" ("\\" + "\\")) to:f
flush f
close f

--Find out what the max default is, check if it has scriptmanager installed.

--Opening registry, checking for default 3dsMax path
registry.openKey HKEY_LOCAL_MACHINE "SOFTWARE" accessRights:#readOnly key:&theFirst_key1
registry.openKey theFirst_key1 "Classes" accessRights:#readOnly key:&theFirst_key2
registry.openKey theFirst_key2 "3dsmax" accessRights:#readOnly key:&theFirst_key3
registry.openKey theFirst_key3 "DefaultIcon" accessRights:#readOnly key:&theFirst_key4
registry.getValueName theFirst_key4 1 name:&theFirst_theValName
registry.queryValue theFirst_key4 theFirst_theValName type:&theFirst_theType value:&theFirst_theValue
def_max_install = pathConfig.removePathLeaf(pathConfig.removePathLeaf(pathConfig.removePathLeaf(substring theFirst_theValue 2 (theFirst_theValue.count - 2)))) + "\\3dsmax.exe" --This is the path

has_MSM_installed = false

for f in getFiles (b + "\\MaxScriptManager\\*MaxPath.txt") do
(
inputData =#()
g = openfile f
while (not eof g) do
(
append inputData (readLine g)
)
close g

for n in inputData do
(
if n == def_max_install do
(
has_MSM_installed = true
)
)
)

--Delete mzpfile in the registry
registry.createKey HKEY_LOCAL_MACHINE ("Software\\Classes\\mzpfile\\") accessRights:#all newKeyCreated:&newKeyCreated key:&key1
registry.deleteKey key1 recurse:true

--The following info is either there or always has to be there on INSTALL
--Associates MZP file...
registry.createKey HKEY_CLASSES_ROOT ".mzp" accessRights:#all key:&def_info1
registry.setvalue def_info1 "" #REG_SZ "mzpfile"
registry.createKey HKEY_CLASSES_ROOT "mzpfile" accessRights:#all key:&def_info2
registry.setvalue def_info2 "" #REG_SZ "MaxScript MZP Installer"
--Default Icon
registry.createKey HKEY_CLASSES_ROOT ("mzpfile\\DefaultIcon\\") accessRights:#all key:&def_info3
registry.setvalue def_info3 "" #REG_SZ (b + "\\MaxScriptManager\\MaxScriptManager.exe")

--Delete msr in the registry
registry.createKey HKEY_LOCAL_MACHINE ("Software\\Classes\\3dsmsr\\") accessRights:#all newKeyCreated:&newKeyCreated key:&msr_key1
registry.deleteKey msr_key1 recurse:true

--The following info is either there or always has to be there on INSTALL
--Associates MSR file...
registry.createKey HKEY_CLASSES_ROOT ".msr" accessRights:#all key:&msr_def_info1
registry.setvalue msr_def_info1 "" #REG_SZ "3dsmsr"
registry.createKey HKEY_CLASSES_ROOT "3dsmsr" accessRights:#all key:&msr_def_info2
registry.setvalue msr_def_info2 "" #REG_SZ "MaxScript Repository"
--Default Icon
registry.createKey HKEY_CLASSES_ROOT ("3dsmsr\\DefaultIcon\\") accessRights:#all key:&msr_def_info3
registry.setvalue msr_def_info3 "" #REG_SZ (b + "\\MaxScriptManager\\MSR.ico")

--Delete ms,mse,mcr in the registry
the3dsMaxInstalls = #("open_3dsMax_9_-_32bit","open_3dsMax_9_-_64bit","open_3dsMaxDesign_9_-_32bit","open_3dsMaxDesign_9_-_64bit","open_3dsMax_2008_-_32bit","open_3dsMax_2008_-_64bit","open_3dsMaxDesign_2008_-_32bit","open_3dsMaxDesign_2008_-_64bit","open_3dsMax_2009_-_32bit","open_3dsMax_2009_-_64bit","open_3dsMaxDesign_2009_-_32bit","open_3dsMaxDesign_2009_-_64bit","open_3dsMax_2010_-_32bit","open_3dsMax_2010_-_64bit","open_3dsMaxDesign_2010_-_32bit","open_3dsMaxDesign_2010_-_64bit","open_3dsMax_2011_-_32bit","open_3dsMax_2011_-_64bit","open_3dsMaxDesign_2011_-_32bit","open_3dsMaxDesign_2011_-_64bit","open_3dsMax_2012_-_32bit","open_3dsMax_2012_-_64bit","open_3dsMaxDesign_2012_-_32bit","open_3dsMaxDesign_2012_-_64bit")
for n in the3dsMaxInstalls do
(
registry.createKey HKEY_LOCAL_MACHINE ("Software\\Classes\\3dsms\\Shell\\" + n) accessRights:#all newKeyCreated:&newKeyCreated key:&remove_ms_key1
registry.deleteKey remove_ms_key1 recurse:true

registry.createKey HKEY_LOCAL_MACHINE ("Software\\Classes\\3dsmse\\Shell\\" + n) accessRights:#all newKeyCreated:&newKeyCreated key:&remove_mse_key1
registry.deleteKey remove_mse_key1 recurse:true

registry.createKey HKEY_LOCAL_MACHINE ("Software\\Classes\\3dsmcr\\Shell\\" + n) accessRights:#all newKeyCreated:&newKeyCreated key:&remove_mcr_key1
registry.deleteKey remove_mcr_key1 recurse:true
)

fn ms_mse_mcr_registry thefiletype underscore no_underscore=
(
--Icon
registry.createKey HKEY_CLASSES_ROOT (thefiletype + "\\shell\\open_" + underscore + "\\") accessRights:#all key:&add_ft1
registry.setvalue add_ft1 "Icon" #REG_SZ (b + "\\MaxScriptManager\\MaxScriptManager.exe")
--ContextMenu string
registry.createKey HKEY_CLASSES_ROOT (thefiletype + "\\shell\\open_" + underscore + "\\") accessRights:#all key:&add_ft2
registry.setvalue add_ft2 "" #REG_SZ ("Install with " + no_underscore)
--open command
registry.createKey HKEY_CLASSES_ROOT (thefiletype + "\\shell\\open_" + underscore + "\\command\\") accessRights:#all key:&add_ft3
registry.setvalue add_ft3 "" #REG_SZ (b + "\\MaxScriptManager\\MaxScriptManager.exe \"%1\"" + " " + underscore)
)

the3dsMaxinstalls = #()
for f in getFiles (b + "\\MaxScriptManager\\*MaxPath.txt") do
(
append the3dsMaxinstalls f
)

sort the3dsMaxinstalls
the3dsMaxinstalls = for i = the3dsMaxinstalls.count to 1 by -1 collect the3dsMaxinstalls[i]

for f in the3dsMaxinstalls do
(
filename = getFileNameFile f
filteredstring = filterString filename "_"
with_underscore = filteredstring[1] + "_" + filteredstring[2] + "_" + filteredstring[3] + "_" + filteredstring[4]
without_underscore = filteredstring[1] + " " + filteredstring[2] + " " + filteredstring[3] + " " + filteredstring[4]
--MZP
--Icon
registry.createKey HKEY_CLASSES_ROOT ("mzpfile\\shell\\open_" + with_underscore + "\\") accessRights:#all key:&def_info7
registry.setvalue def_info7 "Icon" #REG_SZ (b + "\\MaxScriptManager\\MaxScriptManager.exe")
--ContextMenu String
registry.createKey HKEY_CLASSES_ROOT ("mzpfile\\shell\\open_" + with_underscore + "\\") accessRights:#all key:&def_info8
registry.setvalue def_info8 "" #REG_SZ ("Install with " + without_underscore)
--open command
registry.createKey HKEY_CLASSES_ROOT ("mzpfile\\shell\\open_" + with_underscore + "\\command\\") accessRights:#all key:&def_info6
registry.setvalue def_info6 "" #REG_SZ (b + "\\MaxScriptManager\\MaxScriptManager.exe \"%1\"" + " " + with_underscore)

--MSR
--Icon
registry.createKey HKEY_CLASSES_ROOT ("3dsmsr\\shell\\open_" + with_underscore + "\\") accessRights:#all key:&msr_def_info7
registry.setvalue msr_def_info7 "Icon" #REG_SZ (b + "\\MaxScriptManager\\MSR.ico")
--ContextMenu String
registry.createKey HKEY_CLASSES_ROOT ("3dsmsr\\shell\\open_" + with_underscore + "\\") accessRights:#all key:&msr_def_info8
registry.setvalue msr_def_info8 "" #REG_SZ ("Install with " + without_underscore)
--open command
registry.createKey HKEY_CLASSES_ROOT ("3dsmsr\\shell\\open_" + with_underscore + "\\command\\") accessRights:#all key:&msr_def_info6
registry.setvalue msr_def_info6 "" #REG_SZ (b + "\\MaxScriptManager\\MaxScriptManager.exe \"%1\"" + " " + with_underscore)

--MS,MSE,MCR
ms_mse_mcr_registry "3dsms" with_underscore without_underscore
ms_mse_mcr_registry "3dsmse" with_underscore without_underscore
ms_mse_mcr_registry "3dsmcr" with_underscore without_underscore
)

theFiles = #()
for f in getFiles (b + "\\MaxScriptManager\\*MaxPath.txt") do
(
append theFiles f
)

theFiles = for i = theFiles.count to 1 by -1 collect theFiles[i]

if has_MSM_installed == true then
(
--The default 3dsMax also has scriptmanager installed

for f in theFiles do
(
inputData =#()
g = openfile f
while (not eof g) do
(
append inputData (readLine g)
)
close g

for n in inputData do
(
if n == def_max_install do
(
filename = getFileNameFile f
filteredstring = filterString filename "_"
with_underscore = filteredstring[1] + "_" + filteredstring[2] + "_" + filteredstring[3] + "_" + filteredstring[4]

--DEFAULT INFO

--MZP
--Context string
registry.createKey HKEY_CLASSES_ROOT ("mzpfile\\shell\\open\\") accessRights:#all key:&def2_info4_4
registry.setvalue def2_info4_4 "Icon" #REG_SZ (b + "\\MaxScriptManager\\MaxScriptManager.exe")
--Icon
registry.createKey HKEY_CLASSES_ROOT ("mzpfile\\shell\\open\\") accessRights:#all key:&def2_info5_4
registry.setvalue def2_info5_4 "" #REG_SZ ("Install with default 3dsMax")
--default open command
registry.createKey HKEY_CLASSES_ROOT ("mzpfile\\shell\\open\\command\\") accessRights:#all key:&def2_info3
registry.setvalue def2_info3 "" #REG_SZ (b + "\\MaxScriptManager\\MaxScriptManager.exe \"%1\"" + " " + with_underscore)

--MSR
--Context string
registry.createKey HKEY_CLASSES_ROOT ("3dsmsr\\shell\\open\\") accessRights:#all key:&msr_def2_info4_4
registry.setvalue msr_def2_info4_4 "Icon" #REG_SZ (b + "\\MaxScriptManager\\MSR.ico")
--Icon
registry.createKey HKEY_CLASSES_ROOT ("3dsmsr\\shell\\open\\") accessRights:#all key:&msr_def2_info5_4
registry.setvalue msr_def2_info5_4 "" #REG_SZ ("Install with default 3dsMax")
--default open command
registry.createKey HKEY_CLASSES_ROOT ("3dsmsr\\shell\\open\\command\\") accessRights:#all key:&msr_def2_info3
registry.setvalue msr_def2_info3 "" #REG_SZ (b + "\\MaxScriptManager\\MaxScriptManager.exe \"%1\"" + " " + with_underscore)

)
)
)
)
else
(
theFiles = #()
for f in getFiles (b + "\\MaxScriptManager\\*MaxPath.txt") do
(
append theFiles f
)

filename = getFileNameFile theFiles[1]
filteredstring = filterString filename "_"
with_underscore = filteredstring[1] + "_" + filteredstring[2] + "_" + filteredstring[3] + "_" + filteredstring[4]
--DEFAULT INFO
--MZP
--Context string
registry.createKey HKEY_CLASSES_ROOT ("mzpfile\\shell\\open\\") accessRights:#all key:&def2_info4_4
registry.setvalue def2_info4_4 "Icon" #REG_SZ (b + "\\MaxScriptManager\\MaxScriptManager.exe")
--Icon
registry.createKey HKEY_CLASSES_ROOT ("mzpfile\\shell\\open\\") accessRights:#all key:&def2_info5_4
registry.setvalue def2_info5_4 "" #REG_SZ ("Install with default 3dsMax")
--default open command
registry.createKey HKEY_CLASSES_ROOT ("mzpfile\\shell\\open\\command\\") accessRights:#all key:&def2_info3
registry.setvalue def2_info3 "" #REG_SZ (b + "\\MaxScriptManager\\MaxScriptManager.exe \"%1\"" + " " + with_underscore)

--MSR
--Context string
registry.createKey HKEY_CLASSES_ROOT ("3dsmsr\\shell\\open\\") accessRights:#all key:&msr_def2_info4_4
registry.setvalue msr_def2_info4_4 "Icon" #REG_SZ (b + "\\MaxScriptManager\\MSR.ico")
--Icon
registry.createKey HKEY_CLASSES_ROOT ("3dsmsr\\shell\\open\\") accessRights:#all key:&msr_def2_info5_4
registry.setvalue msr_def2_info5_4 "" #REG_SZ ("Install with default 3dsMax")
--default open command
registry.createKey HKEY_CLASSES_ROOT ("3dsmsr\\shell\\open\\command\\") accessRights:#all key:&msr_def2_info3
registry.setvalue msr_def2_info3 "" #REG_SZ (b + "\\MaxScriptManager\\MaxScriptManager.exe \"%1\"" + " " + with_underscore)
)

setINIsetting "$userscripts\\MaxScriptManager\\Settings.ini" "About" "Version" "0.2 BETA"

renameFile "$userscripts\\MaxScriptManager\\Norman3D-MaxScriptManager.mcr" (pathConfig.removePathLeaf((symbolicPaths.getPathValue "$userscripts")) + "\\ui\\usermacros\\Norman3D-MaxScriptManager.mcr")
filein (pathConfig.removePathLeaf((symbolicPaths.getPathValue "$userscripts")) + "\\ui\\usermacros\\Norman3D-MaxScriptManager.mcr")

renameFile "$userscripts\\MaxScriptManager\\Norman3D-MaxScriptManager_RunScript.mcr" (pathConfig.removePathLeaf((symbolicPaths.getPathValue "$userscripts")) + "\\ui\\usermacros\\Norman3D-MaxScriptManager_RunScript.mcr")
filein (pathConfig.removePathLeaf((symbolicPaths.getPathValue "$userscripts")) + "\\ui\\usermacros\\Norman3D-MaxScriptManager_RunScript.mcr")

filein "$userscripts\\MaxScriptManager\\MSM_Functions.ms"
NotifyIcon "default"

--Add Repository
if doesFileExist "$userscripts\\MaxScriptManager\\Repositories\\Repositories.ini" == false do
(
setINIsetting "$userScripts\\MaxScriptManager\\Repositories\\Repositories.ini" "Repositories" "Count" "1"
setINIsetting "$userScripts\\MaxScriptManager\\Repositories\\Repositories.ini" "Repositories" "Item_1" "http://www.norman3d.com/repo.msr"
)

--Add Icon
--This is the path to MaxStartUI
maintoolbar_file = pathConfig.removePathLeaf((symbolicPaths.getPathValue "$userscripts")) + "\\ui\\MaxStartUI.cui"
--First save our current CUI file as the MaxStartUI.cui
deleteFile maintoolbar_file
cui.saveConfigAs maintoolbar_file

--Let us get all the available toolbars
theArray = (dotnetClass "System.IO.File").ReadAllLines maintoolbar_file
theToolbars = #()
for n in theArray do
(
if matchpattern n pattern:"[*]" do
(
ss = subString n 2 (n.count - 2)
ItemCount = getINIsetting maintoolbar_file ss "ItemCount"
if ItemCount != "" do
(
append theToolbars ss
)
)
)

found_item = false
--Search in all the toolbars
for t in theToolbars do
(
item_list = #()
single_item = #()

--Get ItemCount
current_itemcount = (getINISetting maintoolbar_file t "ItemCount") as integer

--Check if the Icon is already there...
for i = 0 to current_itemcount do
(
if matchpattern (getINISetting maintoolbar_file t ("Item"+(i as string))) pattern:"*MaxScriptManager*" == true do
(
--It seems to be there!
found_item = true
)
)
)

--If Icon is not found go ahead and install it!
if found_item == false do
(
current_itemcount = (getINISetting maintoolbar_file "Main Toolbar" "ItemCount") as integer

--Gets the button size
button_sizes_array = filterString (getINISetting maintoolbar_file "Main Toolbar" "Drect" as string) " "
button_size = (button_sizes_array[button_sizes_array.count] as integer) - 60

--New Drect and CurPos numbers
--if the button has an icon it has to add "23" or "32", deppending on the size of the buttons.
set_drect = ((button_sizes_array[button_sizes_array.count - 1] as integer) + button_size) as string

--Replace the Drect and CurPos numbers (both will have the same number)
setINISetting maintoolbar_file "Main Toolbar" "Drect" (substituteString (getINISetting maintoolbar_file "Main Toolbar" "Drect" as string) (button_sizes_array[button_sizes_array.count - 1]) set_drect)
setINISetting maintoolbar_file "Main Toolbar" "CurPos" (substituteString (getINISetting maintoolbar_file "Main Toolbar" "CurPos" as string) (button_sizes_array[button_sizes_array.count - 1]) set_drect)

--Add 1 to ItemCount
setINISetting maintoolbar_file "Main Toolbar" "ItemCount" ((current_itemcount + 1) as string)

--Add new Item
setINISetting maintoolbar_file "Main Toolbar" ("Item"+((current_itemcount) as string)) ("2|0|0|31|3|647394|MaxScriptManager`Norman3D|0|0|" + "\"" + "MaxScriptManager" + "\"" + "|" + "\"" + "MSM" + "\"" + "|-1|")

--Finally we reload the MaxStartUI
cui.loadConfig maintoolbar_file
)

/*
Replaces all entries called "Run Script..." in the menus with custom one.
*/

--Replace the original macro with custom one
mainmenu_file = pathConfig.removePathLeaf((symbolicPaths.getPathValue "$userscripts")) + "\\ui\\MaxStartUI.mnu"

NumberOfMenus = (getINIsetting mainmenu_file "MenuManager" "NumberOfMenus") as integer
for i=0 to NumberOfMenus do
(
ItemCount = (getINIsetting mainmenu_file ("Menu_" + (i as string)) "ItemCount") as integer
for j=0 to ItemCount do
(
ItemAction = getINIsetting mainmenu_file ("Menu_" + (i as string)) ("Item" + (j as string) + "_Action")
if ItemAction == "0|40470" do
(
setINIsetting mainmenu_file ("Menu_" + (i as string)) ("Item" + (j as string) + "_Action") ("647394|MaxScriptManager_RunScript`Norman3D")
)
)
)

menuMan.loadMenuFile mainmenu_file

--SetINISettings
MAXScriptManager_SettingsFile = "$userscripts\\MAXScriptManager\\Settings.ini"

chkUpdatesStartup_INI = getINISetting MAXScriptManager_SettingsFile "Settings" "chkUpdatesStartup"
chkAutoUpdateStartup_INI = getINISetting MAXScriptManager_SettingsFile "Settings" "chkAutoUpdateStartup"
chkIconNotifier_INI = getINISetting MAXScriptManager_SettingsFile "Settings" "chkIconNotifier"
chkAddIconsToolbar_INI = getINISetting MAXScriptManager_SettingsFile "Settings" "chkAddIconsToolbar"
Toolbar_INI = getINISetting MAXScriptManager_SettingsFile "Settings" "Toolbar"
changelist_INI = getINISetting MAXScriptManager_SettingsFile "Changelist" "Hidden"

if chkUpdatesStartup_INI == "" do (setINISetting MAXScriptManager_SettingsFile "Settings" "chkUpdatesStartup" "true")
if chkAutoUpdateStartup_INI == "" do (setINISetting MAXScriptManager_SettingsFile "Settings" "chkAutoUpdateStartup" "false")
if chkIconNotifier_INI == "" do (setINISetting MAXScriptManager_SettingsFile "Settings" "chkIconNotifier" "true")
if chkAddIconsToolbar_INI == "" do (setINISetting MAXScriptManager_SettingsFile "Settings" "chkAddIconsToolbar" "true")
if Toolbar_INI == "" do (setINISetting MAXScriptManager_SettingsFile "Settings" "Toolbar" "Main Toolbar")
if changelist_INI == "" do (setINISetting MAXScriptManager_SettingsFile "Changelist" "Hidden" "false")

--RunStartup
filein "$userscripts\\startup\\MSM_Startup.ms"

if (getINISetting MAXScriptManager_SettingsFile "Changelist" "Hidden") == "false" do
(
filein "$userscripts\\MaxScriptManager\\MSM_Changelist.ms"
)