Executing External Commands and Programs

MAXScript provides two methods for executing external programs - DOSCommand() and ShellLaunch().

DOSCommand() takes a DOS command as a string and send it to the system for execution. It has the form:

DOSCommand <command_string>



DOSCommand "delete c:\\temp\\foo.dat"

DOSCommand ("copy " + source_file + " " + dest_folder)

You can use this function to launch other programs, for example, or perform such tasks as gathering all the material texture and displacement image files in your scene into one folder.

The DOSCommand() function returns an integer which is the status result returned by the executed system command.


ShellLaunch() emulates the double-clicking on a specified file in Windows.

It has the form:

ShellLaunch <filename_string> <parameters_string>


Whatever you send to ShellLaunch will be run by the Windows shell automatically.

For example

ShellLaunch "E:\\tests\\lookup.html" ""

would launch the default Web Browser with lookup.html.

If a file-name extension is not specified in <filename_string>, Windows will search the specified directory for executable files. If no directory is specified, Windows will search the paths in the Path environment variable for the executable file.

For example:

shellLaunch "e:/program files/ucalc/ucalc" ""

will execute the ucalc.exe file in the specified directory.

The <parameters_string> is passed to the launched application as command line parameters.

For example:

shellLaunch "e:/t.avi" "/play /loop"

Will launch the application associated with .avi files, and pass /play and /loop as command line parameters.