LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

I can

't get the 'system' function in C working in the CVI/NT environment. This is the first time I'm using C/CVI on the NT. I have no problems using the 'system' function on a UNIX machine. Does CVI support this function? Does it work differently on the NT?
0 Kudos
Message 1 of 5
(4,891 Views)
't get the 'system' function in C working in the CVI/NT environment. This is the first time I'm using C/CVI on the NT. I have no problems using the 'system' function on a UNIX machine. Does CVI support this function? Does it work differently on the NT?I just tested this function and it worked fine on NT. You must have the filename/path wrong. Are you using \\ for \. Remember, backslash is an escape code character so you have to put two of them. Here is an example:

system("C:\\WINNT\\notepad.exe");

Hope this helps,

Chris Matthews
Measurement Studio Support Manager
Message 2 of 5
(4,891 Views)
't get the 'system' function in C working in the CVI/NT environment. This is the first time I'm using C/CVI on the NT. I have no problems using the 'system' function on a UNIX machine. Does CVI support this function? Does it work differently on the NT?Thank you! I tried your example and it worked, but I'm trying to write a directory listing to a file. For instance:

system("dir C:\\WINNT > dir.lst");

and I get a non-fatal runtime error. Would this be considered a DOS command and I need to do something different? I don't have much experience programming in the Windows/NT environment.
0 Kudos
Message 3 of 5
(4,891 Views)
't get the 'system' function in C working in the CVI/NT environment. This is the first time I'm using C/CVI on the NT. I have no problems using the 'system' function on a UNIX machine. Does CVI support this function? Does it work differently on the NT?Nevermind! I figured it out. I need to specifiy the command line interpreter.

system ("cmd /c dir > com1");

I should learn to look at my NT book more often...
0 Kudos
Message 4 of 5
(4,891 Views)
't get the 'system' function in C working in the CVI/NT environment. This is the first time I'm using C/CVI on the NT. I have no problems using the 'system' function on a UNIX machine. Does CVI support this function? Does it work differently on the NT?CindyC writes:
> Thank you! I tried your example and it worked, but I'm trying to
> write a directory listing to a file. For instance:
>
> system("dir C:\\WINNT > dir.lst");
>
> and I get a non-fatal runtime error. Would this be considered a DOS
> command and I need to do something different? I don't have much
> experience programming in the Windows/NT environment.

The following calls should work:

system("command.com /C dir C:\\WINNT > dir.lst");
system("cmd.exe /C dir C:\\WINNT > dir.lst");

command.com and cmd.exe are the command line interpreters on Windows,
similar to shells on Unix (bash, ksh, csh, tcsh, etc). Note that
cmd.exe is available only on WinNT/2000 not on Win95/98. So if you
want to issue a shell command
you need to prefix it with the command
interpreter. The option /C just tells the interpreter to execute the
following command and then to exit.

You don't need to specify the command interpreter if you don't need
its functionality (output redirection, etc), e.g:

system("C:\\WINNT\\notepad.exe");

When I run your function call I see a shell window briefly popping up,
displaying the directory contents, and then exiting. In other words
the output is not redirected to the file.

However, I was unable to reproduce the non-fatal runtime error. What
error message were you getting exactly?

Peter

-- Peter Ilberg
0 Kudos
Message 5 of 5
(4,891 Views)