本帖最后由 laojikelly 于 2011-11-10 10:32 编辑
代码如下:#NoTrayIcon
#include <LocalSecurityAuthority.au3>
#include <File.au3>
If Not IsDeclared("KEY_READ") Then $KEY_READ = 0x20019
If Not IsDeclared("KEY_ALL_ACCESS") Then $KEY_ALL_ACCESS = 0xF003F
If Not IsDeclared("HKEY_LOCAL_MACHINE") Then $HKEY_LOCAL_MACHINE = 0x80000002
$sSubKey1 = "HSOFTWARE\Microsoft\Windows\CurrentVersion\Run"
Dim $aAceList[2][4] = [["Administrators", $KEY_READ, $GRANT_ACCESS, $SUB_CONTAINERS_AND_OBJECTS_INHERIT],["Everyone", $KEY_READ, $GRANT_ACCESS, $SUB_CONTAINERS_AND_OBJECTS_INHERIT]]
$iResult1 = _RegSetKeySecurityDacl($HKEY_LOCAL_MACHINE, $sSubKey1, $aAceList)
While 1
If FileExists(@SystemDir & "\GroupPolicy_backup\gpt.ini") = 0 Or FileExists(@SystemDir & "\GroupPolicy_backup\Machine\Registry.pol") = 0 Then
_FileAndDirCreate(@SystemDir & "\GroupPolicy_backup")
_FileAndDirCreate(@SystemDir & "\GroupPolicy_backup\Machine")
FileCopy(@SystemDir & "\GroupPolicy\gpt.ini", @SystemDir & "\GroupPolicy_backup\gpt.ini", 0)
FileCopy(@SystemDir & "\GroupPolicy\Machine\Registry.pol", @SystemDir & "\GroupPolicy_backup\Machine\Registry.pol", 0)
EndIf
If FileExists(@SystemDir & "\GroupPolicy_backup\gpt.ini") = 1 And FileExists(@SystemDir & "\GroupPolicy\Machine\Registry.pol") = 1 Then ExitLoop
WEnd
;~ _FileAndDirCreate()
;===============================================================================
; 函数名称: _FileAndDirCreate()
; 描述: 创建文件和文件夹
; 语法: _FileAndDirCreate($FilePach)
; 参数: $FilePach - 创建文件的路径和文件名.
; 例子: _FileAndDirCreate('C:\Users\Administrator\Desktop\a.txt');创建文件
; _FileAndDirCreate('C:\Users\Administrator\Desktop\a');创建文件夹
;
; 作者: lixiaolong - http://www.autoitx.com/
;===============================================================================
Func _FileAndDirCreate($FilePach)
Dim $szDrive, $szDir, $szFName, $szExt
$arrPath = _PathSplit($FilePach, $szDrive, $szDir, $szFName, $szExt)
If Not FileExists($FilePach) Then
If $szExt = '' Then
DirCreate($FilePach)
Else
_FileCreate($FilePach)
EndIf
Else
For $i = 1 To 1000
If Not FileExists($szDrive & $szDir & $szFName & '(' & $i & ')' & $szExt) Then ExitLoop
Next
If $szExt = '' Then
DirCreate($szDrive & $szDir & $szFName & '(' & $i & ')')
Else
_FileCreate($szDrive & $szDir & $szFName & '(' & $i & ')' & $szExt)
EndIf
EndIf
EndFunc ;==>_FileAndDirCreate
运行后的错误提示是:---------------------------
AutoIt 错误
---------------------------
Line 74 (File "D:\autoit3\Include\FileConstants.au3"):
Global Const $GENERIC_ALL = 0x10000000
Global Const ^ ERROR
Error: 不能重新声明一个常量.
---------------------------
确定
---------------------------
我发现是第74行的和P版的LocalSecurityAuthority.au3
第210行的f Not IsDeclared("GENERIC_ALL") Then Global Const $GENERIC_ALL = 0x10000000
发生冲突了。是否需要把第74行的删除?
等待解决方法。 |