O
oddstray
Hi,
I'm using WinXP. I wrote a short C utility in which I want to change
directories and run programs. When I use the system() method and pass
in the same command that works in a cmd.exe session, it claims "Unable
to locate the directory". This happens for directories with and
without spaces in their names. Can anyone tell me what's wrong?
Thanks.
B
Here's the code snippet that fails:
if( _chdir( "C:" ) != 0 )
printf( "Unable to locate the directory: %s\n", "C:" );
else
system( "dir *.*");
// WORKS THIS FAR
if( _wchdir( "cd Perl" ) != 0 )
printf( "Unable to locate the directory: %s\n", "Perl" );
else
system( "dir *.*");
if( _wchdir( "cd C:\\Perl" ) != 0 )
printf( "Unable to locate the directory: %s\n", "C:\\Perl" );
else
system( "dir *.*");
// 'UNABLE TO LOCATE' EITHER OF THESE ALTHOUGH THIS DIRECTORY DOES
EXIST
I'm using WinXP. I wrote a short C utility in which I want to change
directories and run programs. When I use the system() method and pass
in the same command that works in a cmd.exe session, it claims "Unable
to locate the directory". This happens for directories with and
without spaces in their names. Can anyone tell me what's wrong?
Thanks.
B
Here's the code snippet that fails:
if( _chdir( "C:" ) != 0 )
printf( "Unable to locate the directory: %s\n", "C:" );
else
system( "dir *.*");
// WORKS THIS FAR
if( _wchdir( "cd Perl" ) != 0 )
printf( "Unable to locate the directory: %s\n", "Perl" );
else
system( "dir *.*");
if( _wchdir( "cd C:\\Perl" ) != 0 )
printf( "Unable to locate the directory: %s\n", "C:\\Perl" );
else
system( "dir *.*");
// 'UNABLE TO LOCATE' EITHER OF THESE ALTHOUGH THIS DIRECTORY DOES
EXIST