How do I use ExecuteMaxscriptCommand


There is a method in C#, I want to use it to run a Maxscript string.

public void YGB(string ms)
MaxscriptSDK.ExecuteMaxscriptCommand (ms);

I found that there are two methods in different 3ds max versions,

MaxscriptSDK.ExecuteMaxscriptCommand(ms, 1); //in 3ds max 2022

I wonder if there’s an easier way to run/execute maxscript string,Or is there a way to make it work in different 3ds max versions. I know this has been discussed before, but not clearly:


use reflection

in the end it would be smth like this :rofl:


void ExecuteAnyVersion( string script )	
	int max_version = Funcs.GetMaxVersion();

	switch( max_version )
		case 2023:
			var extra_arg = Funcs.GetExtraArgForVersion(max_version);
			Type t = typeof(Funcs);
			t.GetMethod("Execute").Invoke( null, new object[]{ script, extra_arg });
		case 2024:
		case 2025:
		case 2026:
		case 2027:
			var extra_arg = Funcs.GetExtraArgForVersion(max_version);
			var autodesk_security_cookie = Funcs.GetAutodeskPermissionToExecuteScripts(max_version);
			Type t = typeof(Funcs);
			t.GetMethod("Execute").Invoke( null, new object[]{ script, extra_arg, autodesk_security_cookie });
			Funcs.Execute( "older max versions" );

static public class Funcs
	static public void Execute( string str )
		Console.WriteLine( $"--> {str}");


Thanks for your reply, but the “MaxscriptSDK” is an abstract class, Things are getting complicated. I’m trying to rewrite a derived class, But I failed.

t = dotNet.getType (dotNetClass "managedservices.maxscriptsdk")
method = t.getmethod "ExecuteMaxscriptCommand"
method.Invoke undefined #( "messageBox \"wow\"" )


Your method is feasible,But there are two parameters about “ExecuteMaxscriptCommand” in 3dsmax higher version(2022+). I can only write two styles by version judgment.


I doubt that it is possible to make a version agnostic method that would work for every future version, since you never know what args AD would want you to provide on invocation. Technically you can analyze which args are expected using reflection, but I’m not sure it can help much to create them without knowing the logic of their usage upfront.


Since it’s such a hassle, So can we find another way to run maxscript string in a c# method. in other words, We abandon the use of “ExecuteMaxscriptCommand” method.


if it is about execution of a script file then you could insert filein “/path_to/” into mini listener window and send enter key to execute it.


I need this functionality for encryption and decryption, If you expose the string, it’s meaningless


why’s that? obfuscate it and put it in .mse, then filein the .mse file.
Swap a few bytes in the beginning of the file and this mse file will become unextractable by the tools found on the internet. Of course, you’ll need to swap these bytes back and forth with some helper script to run it, but at least it will stop majority of hackers
Maxscript is an interpreted language so you can’t skip the process of parsing the source, so it is available as a plain text anyway.
Can you prevent anyone to set a breakpoint on every native function that is used to execute scripts.? No, you can’t


This encryption method has not been tried. Do you have any good tutorials to recommend.


Actually it was, try this tool. Last time I checked it was wrapping encrypted code with obfuscated c#.


不用研究这种方式加解密了, 可以完整的获取到源码.


Why do you encrypt your message so we have to go to google translate? I could answer in my native language but would it make sense to anyone here?
Perhaps the only way to secure scripts is to break them into multiple parts, evaluate them separately and mixed with a bunch of trash code that make no sense whatsoever and then combine these parts into a single script. But I don’t get why anyone would waste so much time for a script both protecting and hacking it


more and more person from China begin to write mxs , but most for hacking and malware ,that’s why Autodesk release security tool , for most people , we talk with english with others who are not Chinese , and ourselves use Han , but lots of self-proclaimed professionals contrary

I didn’t know how to inherit maxscriptsdk,so I use ExecuteMaxscriptscript instead , the sdk has inherited it in GlobalInterface , I use this to communicate with other app


Sorry, I forgot to convert to English


I use ExecuteMaxscriptscript in Some versions. Such as 3dsmax 2020, It’s not working. I don’t know why!


maybe the banned control or interface ,when installed security tool or from 2023 ,no banned controls could initialize while max openning , for this , need to create a ms file , then filein it , delete last


When we are using ExecuteMaxscriptscript , It is easy to be intercepted, Is there no direct run/Execute byte[] using some maxsdk method.