# Command A Commandline Based Tool

**URL:** https://forum.highend3d.com/t/command-a-commandline-based-tool/2046
**Category:** Maya
**Tags:** mel
**Created:** [August 9, 2007, 12:42pm UTC](https://forum.highend3d.com/t/command-a-commandline-based-tool/2046 "2007-08-09T12:42:25Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![dawn3](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/d/ed8c4c/32.png) [@dawn3](https://forum.highend3d.com/u/dawn3)
#### Post date: [August 9, 2007, 12:42pm UTC](https://forum.highend3d.com/t/command-a-commandline-based-tool/2046/1 "2007-08-09T12:42:25Z")

</div>

Mel Users,

I have the following question. A friend of mine made a DOS based exe for file conversions. I have to type within the DOS promt the name of the exe and the flags it needs. the flags differ a lot i.e. resolution, file size .....

Is there a way to directly do this from the script editor.

My solution now is to write the lines of commands to a batch file and run the batch file.

Maybe someone has a smarter solution?

Greetings, regards

Dawn3

---

<div class="post-metadata">

### Author: ![daniel-faust](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@daniel-faust](https://forum.highend3d.com/u/daniel-faust)
#### Post date: [August 9, 2007, 2:30pm UTC](https://forum.highend3d.com/t/command-a-commandline-based-tool/2046/2 "2007-08-09T14:30:51Z")

</div>

read about the "system" command

---

<div class="post-metadata">

### Author: ![dawn3](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/d/ed8c4c/32.png) [@dawn3](https://forum.highend3d.com/u/dawn3)
#### Post date: [August 9, 2007, 2:55pm UTC](https://forum.highend3d.com/t/command-a-commandline-based-tool/2046/3 "2007-08-09T14:55:58Z")

</div>

Thanks Daniel

That was the first area to look but maybe i did not understand it correctly

this seems to be the way to do it....... in the example  
system("start c:/windows/notepad.exe");

but for me it would look like this and its not working  
system("start c:/windows/myprogram.exe -resolution -color -name");

But like i said it does not seem to work ;-(

maybe a little help

---

<div class="post-metadata">

### Author: ![joojaa](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/j/5daacb/32.png) [@joojaa](https://forum.highend3d.com/u/joojaa)
#### Post date: [August 9, 2007, 3:24pm UTC](https://forum.highend3d.com/t/command-a-commandline-based-tool/2046/4 "2007-08-09T15:24:44Z")

</div>

Start is a subshell command for windows applications it forks the execution. ome comd apps doent like it. secondly you usually need to point them to files and yu really ought to type \ instead of /

---

<div class="post-metadata">

### Author: ![daniel-faust](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@daniel-faust](https://forum.highend3d.com/u/daniel-faust)
#### Post date: [August 9, 2007, 4:04pm UTC](https://forum.highend3d.com/t/command-a-commandline-based-tool/2046/5 "2007-08-09T16:04:39Z")

</div>

Some examples

CODE  
menuItem -l ("Open SciTE") -command ("system(\"start \\"C:\\App\\Scintilla Text Editor\\SciTE.exe\\"\");") -echoCommand 1;

menuItem -l ("Open Scripts Folder") -command ("system(\"start explorer \\"C:\\Project\\scripts\\"\");") -echoCommand 1;

menuItem -l ("Open Project") -command ("system(\"load \\"C:\\Project\\usr.sln\\"\");") -echoCommand 1;

system("del \"" + toNativePath($filePath) +&nbsp;&nbsp;"\";"); // delete file

system("start \"C:\App\Nero 7\Nero WaveEditor\waveedit.exe\" \"" + $fileName + "\"");

string $file = `getAttr ($recorder + ".lastSavedFile")`;  
system("load \"" + $file + "\"");

---

<div class="post-metadata">

### Author: ![dawn3](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/d/ed8c4c/32.png) [@dawn3](https://forum.highend3d.com/u/dawn3)
#### Post date: [August 9, 2007, 8:00pm UTC](https://forum.highend3d.com/t/command-a-commandline-based-tool/2046/6 "2007-08-09T20:00:40Z")

</div>

Thanks for all the helpfull posts but you seem to have to do with a dummy 😉

it is clear to me that a program can be launched from maya but i still don't understand how to ad flags to the command utillity.

My normal workflow:  
-open cmd.exe  
-browse to utility (example d:\tmp)  
-type the command (myutil.exe -color -resolution)

the start to do this from maya would probably be   
system("start \"C:\WINDOWS\system32\cmd.exe\"");

but i don't understand the starting of the custom exe with its flags??

Help for a dummy

---

<div class="post-metadata">

### Author: ![daniel-faust](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@daniel-faust](https://forum.highend3d.com/u/daniel-faust)
#### Post date: [August 9, 2007, 8:29pm UTC](https://forum.highend3d.com/t/command-a-commandline-based-tool/2046/7 "2007-08-09T20:29:47Z")

</div>

system is by itself the cmd.exe, so you won't call the cmd.exe.

system load filename: opens the filename with the default application (like when you double click on a non exe file. eg. \*.doc). You don't want that.

system pathToExe.exe: starts the executable and blocks maya until the pathToExe.exe application closes. You may want that.  
system start pathToExe.exe: starts the executable without blocking. This may be what you want.

take a look at this one:  
system("start \"C:\App\Nero 7\Nero WaveEditor\waveedit.exe\" \"" + $fileName + "\"");

this is the same as  
1) launching cmd.exe  
2) typing in "C:\App\Nero 7\Nero WaveEditor\waveedit.exe" "c:\filename.wav"

so you want to do

system("start \"C:\directory\myutil.exe\" -color -resolution");

In the nero example above there is this part \"" + $fileName + "\" this is to end up wiht a string "c:\path to file\file.wav" in quotes because else the command would fail because the waveedit exe would think that only c:\path is the filename. then the wort to would be erroneously passed in as the second argument and file\file.wav as the third argument.

---

<div class="post-metadata">

### Author: ![dawn3](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/d/ed8c4c/32.png) [@dawn3](https://forum.highend3d.com/u/dawn3)
#### Post date: [August 10, 2007, 7:21am UTC](https://forum.highend3d.com/t/command-a-commandline-based-tool/2046/8 "2007-08-10T07:21:52Z")

</div>

Daniel,

Thanks very much, now i understand it correctly and it works.

very nice of you to do the expanation.

Regards,

Dawn3

---

<div class="post-metadata">

### Author: ![joojaa](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/j/5daacb/32.png) [@joojaa](https://forum.highend3d.com/u/joojaa)
#### Post date: [August 10, 2007, 12:24pm UTC](https://forum.highend3d.com/t/command-a-commandline-based-tool/2046/9 "2007-08-10T12:24:59Z")

</div>

QUOTE(Daniel\_Faus @ 08/09/07, 11:29 PM) [snapback]271276[/snapback]  
take a look at this one:  
system("start \"C:\App\Nero 7\Nero WaveEditor\waveedit.exe\" \"" + $fileName + "\"");

this is the same as  
1) launching cmd.exe  
2) typing in "C:\App\Nero 7\Nero WaveEditor\waveedit.exe" "c:\filename.wav"

well actually not, system itself is like launching cmd, but if you launched cmd from cmd you end up with one cmd window And the program, start just forks the execution environment (otherwise maya would wait for the program to terminate to continue the script) without a extra cmd session.

---

<div class="post-metadata">

### Author: ![daniel-faust](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@daniel-faust](https://forum.highend3d.com/u/daniel-faust)
#### Post date: [August 10, 2007, 12:57pm UTC](https://forum.highend3d.com/t/command-a-commandline-based-tool/2046/10 "2007-08-10T12:57:37Z")

</div>

you're right, I agree. So instead of 1) launching cmd.exe I should have writen 1) Open Start/Run...

---

<div class="post-metadata">

### Author: ![dawn3](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/d/ed8c4c/32.png) [@dawn3](https://forum.highend3d.com/u/dawn3)
#### Post date: [August 10, 2007, 3:16pm UTC](https://forum.highend3d.com/t/command-a-commandline-based-tool/2046/11 "2007-08-10T15:16:50Z")

</div>

oke guys...............

A lot of thanks it is working 😉

I dont have to write to batch files anymore but i have another question ;-0 since almost everything is working now.

The commandline tool spits out text for every phase off converting i.e. "first phase finished" "10%" "20%"

is it possible to get this back within the sript editor??

thanks........
