[Closed] Inform about max crash
Everyone knows here, that max may crash because of different reasons. I’m interested to be informed in a file that max crashed. Is there a built in function for that or should I do it somehow else? Any help is appreciated.
as you know when MAX crashes the dialog “Do you want to send log about bla-bla-bla…to Autodesk…” pops-up.
if you attach a letter to this log file – “Dear Autodesk developers, please send me back a reason of my file crash. Sincerely yours, …” – you will get their response back for sure and very soon.
No, no. I don’t want to press anything. I need to receive information that max crashed in a file.
seriously speaking there is nothing built-in for max crash monitoring in general.
probably you can do some sort of MAX process monitoring yourself running standalone program which will check continuity of MAX process (and probably its activity). That’s only solution I see.
Actually, I need to have this monitoring from 3dmax while working on a local network. How do you think if I put a timer to write a crashReport in a shared file which will increment a value every second(let’s say from 0 to 20000), but from a local max to verify the same file 2 times within a period of 3 seconds, if it’s value is the same then print “remote max crashed!!!”
The only think I’m aware is that remote max may be busy sometimes and this increment would not work sometimes.
Something from the depths of computing history raises its ugly head…
Actually, if max crashes, it returns an exit value of -1 ([edit]actually, a crash might return any other value than 0)… So technically, if you don’t mind the inconvenience of having a command prompt open while max is open, you could run max from a .bat file, wait for it to exit, and if it crashes: run a program or do something else:
@echo off
start /w "" "C:\Program Files\Autodesk\3ds Max 2016\3dsmax.exe"
IF %errorlevel% == -1 set /p tmp="Looks like max crashed..."
Does it return -1 even if it’s still displaying error report from Autodesk (I mean if it still opened in task manager)?
In fact, in case of crash, I need to inform about that – write in a file – C:\TEMP\CrashReport.cr – “Crashed TRUE”, restart the same instance of max, but I think it should be closed from Task Manager before this. May be I should do it with PowerShell or exe, like Jorge proposed.
When I tested it, the max process terminated first, returning the value and letting the bat file continue; the error report dialog showed up only later and was an independent process of the command prompt that waited for max. You should be able to restart max while the error report dialog is open.
The powershell equivalent of %errorlevel% is $LASTEXITCODE, so you can rewrite the same exact thing in it if you prefer.
[edit]
Here’s a more complete batch file that does mostly what you want (except testing whether it responds):
@echo off
set maxpath="C:\Program Files\Autodesk\3ds Max 2016\3dsmax.exe"
set reportfilepath="C:\TEMP\CrashReport.cr"
:startmax
echo Starting 3ds max and waiting for it...
start /w "" %maxpath%
IF NOT %errorlevel% == 0 (
echo Crashed TRUE >> %reportfilepath%
echo Max crashed, returning exit code %errorlevel%. Will restart shortly.
GOTO startmax
) ELSE (
set /p tmp="Max didn't crash for once! (Hit enter to close this window.)"
)
If you kill the process via taskkill or task manager, it will also return an exit code, but this time 1. And that’ll make it restart as well.
A small tip: you can start 3ds max with the flag -L to make it load the last opened scene as soon as it starts. Just add the flag to that line, like this: start /w “” %maxpath% -L
There are several ways to do this. The way I would approach it would be as follow:
Whenever Max crashes, it calls an external command-line application “senddmp.exe” to send the report to Autodesk. You can find this application in the 3ds Max root folder.
So, you can write your own command-line application and replace it.
Here is a very simple C# example that creates a tiny .exe file. When it is executed it will open a website. You can replace the URL call to point it to a .PHP page and send an email from there, which is pretty easy to modify in case you need to.
(
fn CreateConsoleAssembly mSource mFilename =
(
cSharp = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
cParameters = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
cParameters.ReferencedAssemblies.Add "System.dll"
cParameters.GenerateInMemory = true
cParameters.CompilerOptions = "/target:winexe"
cParameters.OutputAssembly = mFilename
cResult = cSharp.CompileAssemblyFromSource cParameters #(mSource)
)
scr = "using System;
"
scr += "public class MaxCrashReport
"
scr += "{
"
scr += " public static void Main()
"
scr += " {
"
scr += " System.Diagnostics.Process.Start(\"http://www.polytools3d.com\");
"
scr += " }
"
scr += "}
"
CreateConsoleAssembly scr @"C:\senddmp.exe"
)
Here is a different example that will directly send an email. You must customize the user and server information. Then replace the “senddmp.exe” in your 3ds Max root folder and have a happy crash.
(
fn CreateConsoleAssembly mSource mFilename =
(
cSharp = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
cParameters = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
cParameters.ReferencedAssemblies.Add "System.dll"
cParameters.GenerateInMemory = true
cParameters.CompilerOptions = "/target:winexe"
cParameters.OutputAssembly = mFilename
cResult = cSharp.CompileAssemblyFromSource cParameters #(mSource)
)
-- ================================================================================================
-- CUSTOMIZE YOUR INFOMATION HERE
-- ================================================================================================
FROM_ADRESS = "mike@moldova.com"
TO_ADRESS = "mike@moldova.com"
SUBJECT = "3DS Max Crashed"
MESSAGE = "Tell me and I forget, teach me and I may remember, involve me and I learn."
USER_NAME = "mike@moldova.com"
USER_PASS = "xxxxxxxxxxxxxxxx"
SMTP_HOTS = "smpt.moldova.com"
SMTP_PORT = 25
-- ================================================================================================
scr = "using System;
"
scr += "public class MaxCrashReport
"
scr += "{
"
scr += " public static void Main()
"
scr += " {
"
scr += " System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
"
scr += " System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
"
scr += " System.Net.NetworkCredential credential = new System.Net.NetworkCredential();
"
scr += " message.From = new System.Net.Mail.MailAddress (\"" + FROM_ADRESS + "\");
"
scr += " message.To.Add (\"" + TO_ADRESS + "\");
"
scr += " message.Subject = \"" + SUBJECT + "\";
"
scr += " message.Body = \"" + MESSAGE + "\";
"
scr += " credential.UserName = \"" + USER_NAME + "\";
"
scr += " credential.Password = \"" + USER_PASS + "\";
"
scr += " client.Host = \"" + SMTP_HOTS + "\";
"
scr += " client.Credentials = credential;
"
scr += " client.UseDefaultCredentials = true;
"
scr += " client.Port = " + (SMTP_PORT as string) + ";
"
scr += " client.Send(message);
"
scr += " }
"
scr += "}
"
-- Build .EXE file
CreateConsoleAssembly scr @"C:\senddmp.exe"
)
Needless to say that you should BACKUP the original “senddmp.exe” file.
This code does not handle if the email was actually sent or not.
Note:
None of these methods will handle all Max crashes, but only those where the Send Report application is called.
OMG, You’re all so nice! Thank you for such approaches.
Jorge, you’re really funny, very nice idea and work around :))))
and one more situation is when max is not responding, but still running, then I would like also to stop it from task manager and restart.
Sorry, for so many requirements, but I think this could be helpful to many maxscript developers