我想执行cmd命令,改变文件/文件夹权限对于ntfs文件系统才有效我想判断当前的文件系统是fat/fat32还是ntfs应该怎么做啊??????如果是ntfs就执行下面的下面的cmd命令要在当前程序运行目录下执行才能成功所以我想是否需要先执行一个cd命令?cd C:\Documents and Settings\Administrator\桌面\Soft\InstallUpdate\Debug>
Cacls web /t /e /c /g ASPNET:f这样可以吗?cmd命令下换行怎么写的啊?是否还有更简单的方法?如果先WinExec("cd C:\Documents and Settings\Administrator\桌面\Soft\InstallUpdate\Debug>")
在WinExec("Cacls web /t /e /c /g ASPNET:f")
这样可以吗?

解决方案 »

  1.   

    WinExec没法判断文件系统吧?GetVolumeInformationThe GetVolumeInformation function retrieves information about a file system and volume that have a specified root directory.
    BOOL GetVolumeInformation(
      LPCTSTR lpRootPathName,
      LPTSTR lpVolumeNameBuffer,
      DWORD nVolumeNameSize,
      LPDWORD lpVolumeSerialNumber,
      LPDWORD lpMaximumComponentLength,
      LPDWORD lpFileSystemFlags,
      LPTSTR lpFileSystemNameBuffer,
      DWORD nFileSystemNameSize
    );lpFileSystemNameBuffer 
    [out] Pointer to a buffer that receives the name of the file system (such as the FAT file system or the NTFS file system). 
    nFileSystemNameSize 
    [in] Length of the file system name buffer, in TCHARs. This parameter is ignored if the file system name buffer is not supplied. 
      

  2.   

    如果先WinExec("cd C:\Documents and Settings\Administrator\桌面\Soft\InstallUpdate\Debug>")
    在WinExec("Cacls web /t /e /c /g ASPNET:f")
    这样可以吗?------------------试过了,这样无法成功
    DentistryDoctor(不在无聊中无奈,就在沉默中变态) ( ) 信誉:194    Blog 
    -------------------有详细的例子吗?我是新手
      

  3.   

    我用空格把cd C:\Documents and Settings\Administrator\桌面\Soft\InstallUpdate\Debug Cacls web /t /e /c /g ASPNET:f
    弄成上面这个样子运行也不成功帮帮忙啊
      

  4.   

    用WinExec,如果路径中有空格,应该用""将路径括起来。
    如果可能,请尽可能用CreateProcess来替换。WinExec("cd \"C:\\Documents and Settings\\Administrator\\桌面\\Soft\\InstallUpdate\\Debug\"", ...);WinExec("Cacls web /t /e /c /g ASPNET:f", ...);
      

  5.   

    试过
    CString strCmdStr = "Cacls ";
    strCmdStr += strFileName ;
    strCmdStr += " /t /e /c /g ASPNET:";
    strCmdStr += strRight; CString strPath;
    CUitility util;
    util.GetCurrentDir(strPath);
            CString cdCmdStr="cd ";
    cdCmdStr += strPath;        WinExec(cdCmdStr,SW_HIDE);
    WinExec(strCmdStr,SW_HIDE);这样不行!
      

  6.   

    我在dos命令里直接输入这样的两行却可以
      

  7.   

    你要执行此句干什么?WinExec("cd C:\Documents and Settings\Administrator\桌面\Soft\InstallUpdate\Debug>")一是没必要, 二是如果想设置默认默认,可以用API, SetCurrentDirectory
      

  8.   

    楼主的问题是想问:如何用WinExec来执行多个命令,我想建一个批处理应该可以。