本帖最后由 qqgghh1 于 2011-12-30 17:53 编辑
呵呵,自己搞定。这段代码的目的是为了检测用户电脑各分区USERS账号是否有完全控制,如果没有的话,用USERS账号登陆可能无法正常使用电脑#RequireAdmin
#include <lsasecur.au3>
Local $var = DriveGetDrive( "fixed" )
Local $Remind = "",$j
If NOT @error Then
For $i = 1 to $var[0]
If DriveGetFileSystem($var[$i]) <> "NTFS" Then
$Remind = $Remind&@CRLF&$var[$i]&"分区不是NTFS格式,建议使用convert命令将其转换成NTFS格式"
Else
If $var[$i] <> @HomeDrive Then
checkaccess($var[$i])
If $j = 0 Then $Remind= $Remind&@CRLF&$var[$i]&"分区,users无完全控制权限,【强烈建议】手动添加权限"
EndIf
EndIf
Next
MsgBox(48,"请务必阅读!",$Remind)
EndIf
Func checkaccess($sFilePath)
$j = 0
$iSecur = BitOR($SE_INFO_OWNER, $SE_INFO_DACL)
$pSecur = _SeGetFileSecurity($sFilePath, $iSecur)
If ($pSecur = 0) Then
MsgBox(48, "Error", _SeFormatMsg("_SeGetFileSecurity"))
Exit
EndIf
$pOwner = _SeGetSecurityDescriptorOwner($pSecur)
$pDacl = _SeGetSecurityDescriptorDacl($pSecur)
$sOwner = _SeLookupAccountSid($pOwner)
$aList = _SeEnumEntriesFromAcl($pDacl)
For $i = 1 To $aList[0][0]
If $aList[$i][0] = "BUILTIN\Users" And $aList[$i][2] = 0x001F01FF Then $j = 1
Next
Return $j
EndFunc
#cs
$test = _DriveGetDrive('FIXED') ;返回本地硬盘
_ArrayDisplay($test, '本地硬盘')
;$test = _DriveGetDrive('FIXED', 0) ;返回USB移动硬盘
;_ArrayDisplay($test, 'USB移动硬盘')
Func _DriveGetDrive($type, $flag = 1)
;$flag = 1 返回本地设备;$flag = 0 返回USB移动设备
Local $aDisk[1] = [0], $i
Local $aDrive = DriveGetDrive($type)
For $i = 1 To $aDrive[0]
If $flag = 0 And _WinAPI_GetDriveBusType($aDrive[$i]) = 7 Then
_ArrayAdd($aDisk, StringUpper($aDrive[$i]))
$aDisk[0] += 1
ElseIf $flag = 1 And _WinAPI_GetDriveBusType($aDrive[$i]) <> 7 Then
_ArrayAdd($aDisk, StringUpper($aDrive[$i]))
$aDisk[0] += 1
EndIf
Next
Return $aDisk
EndFunc ;==>_DriveGetDrive 将移动硬盘从fixed中区分出来
#ce
|