Doscommand string

Doscommand string

kenc
Advocate Advocate
1,628 Views
5 Replies
Message 1 of 6

Doscommand string

kenc
Advocate
Advocate

Hi All

 

I am trying to send a string to Doscommand to start Max and run a script.

 

This is my string and doscommand

 

DOSstring = "\"C:\\Program Files\\Autodesk\\3ds Max 2016\\3dsmax.exe\" -U MAXScript " + "O:\\Max Scripts\\Utilities\\Animator Scripts\\CommandlineQueue.ms"

 

doscommand DOSstring

 

 

A max session starts but the script does not run. I know it's something to do with formatting of DOSstring, but I can't figure it out.

 

Thanks in advance.

0 Likes
1,629 Views
5 Replies
Replies (5)
Message 2 of 6

Swordslayer
Advisor
Advisor

Since there's a space in the script filepath, did you try enclosing it in (escaped) quotes the same way it is done with the 3dsmax.exe path?

0 Likes
Message 3 of 6

kenc
Advocate
Advocate

I tried all sorts of combinations, but no go. I'll have to take another go at it.

 

I need to get this straight. After the string completed, each part of the string with spaces should be escaped, correct? Something like

 

" \"max executable path\" -U MAXscript \"max script path\" "

 

BTW, thanks for responding.

0 Likes
Message 4 of 6

Swordslayer
Advisor
Advisor

You need to escape the characters when creating it, otherwise the quotes denote just a start and an end of the string, i.e.:

 

someStringContaining quotes + "\"maxscript path\""

Will result in maxscript path enclosed in quotes to be appended to the original string. That's it, just like you escape a newline character or a tab.

Message 5 of 6

kenc
Advocate
Advocate

I tried everything but no go. If I use only the first DOSstring, max opens.

 

If I use below, the dos window flashes open then closed. From your last reply this should work.

 

DOSstring = "\"C:\\Program Files\\Autodesk\\3ds Max 2016\\3dsmax.exe\" -U MAXScript "

DOSstring = DOSstring +"\"O:\\Max Scripts\\Utilities\\Animator Scripts\\CommandlineQueue.ms\""
doscommand DOSstring

0 Likes
Message 6 of 6

kenc
Advocate
Advocate

Googling this issue, it looks like it's a problem with others. So I took another direction with something I found during Googling.

 

BatchFileName = CurrentRenderFile + "batch.cmd"
BatchFile=openfile BatchFileName mode:"wt"
DOSstring = "\"C:\\Program Files\\Autodesk\\3ds Max 2016\\3dsmax.exe\" -U MAXScript " + "\"O:\\Max Scripts\\Utilities\\Animator Scripts\\CommandlineQueue.ms\""
format "%\n" DOSstring to:BatchFile
close BatchFile
ShellLaunch BatchFileName ""

 

and it works.

 

thanks so much for your help.

0 Likes