LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with system()

I have a string that has the location of a directory I want to make. Ex. c:\mytest\asdf\data
The problem is the previous directories, mytest or asdf, might not exist. Therefore MakeDir would have to be looped searching for '\'.

Instead mkdir in dos works and makes all nessesary directories. When I put in:
LaunchExecutable("command.com /C mkdir c:\\mytest");
or
system("command.com /C mkdir c:\\mytest");
It makes the directory MYTEST

When I put in:
LaunchExecutable("command.com /C mkdir c:\\mytest\\asdf\\data");
or
system("command.com /C mkdir c:\\mytest\\asdf\\data");
It doesn't make any directories.

Why doesn't the second set of commands work?
0 Kudos
Message 1 of 3
(3,876 Views)
The program command.com is the command interpreter for DOS. It doesn't support creating multiple layers of directory with the md or mkdir commands. However, Windows 2000 and Windows XP, give you a command shell application that DOES support that. That is what you are using. If you want to invoke the functionality of the command shell instead of the command interpreter, you would use cmd.exe instead of command.com.

Try this: system("cmd.exe /C mkdir c:\\mytest\\asdf\\data")

That should work,

Chris Matthews
National Instruments
Message 2 of 3
(3,875 Views)
Yeah I'm using Windows xp and that line works. Thank you.
0 Kudos
Message 3 of 3
(3,870 Views)