找回密码
 加入
搜索
查看: 4050|回复: 8

[系统综合] 在AU3里用什么替代批处理Takeown命令?已解决!

  [复制链接]
发表于 2011-6-16 14:18:05 | 显示全部楼层 |阅读模式
本帖最后由 you6591098 于 2011-6-20 15:54 编辑

请问在AU3里用什么去代替Takeown命令
Takeown:管理员成为文件的所有者,可授予管理员恢复对以前被拒绝的文件的访问权限。

以下是微软的解释:
Takeown
使管理员成为文件的所有者,可授予管理员恢复对以前被拒绝的文件的访问权限。

语法
takeown [/s Computer [/u [Domain\User [/p [Password]]]] /f FileName [/a] [/r] [/d {Y | N}]

参数
/sComputer
指定远程计算机名称或 IP 地址(不能使用反斜杠)。该默认值是本地计算机。此参数适用于在命令中指定的所有文件和文件夹。
/uDomain\User
使用特定用户帐户的权限运行脚本。该默认值是系统权限。
/p [Password]
指出 /u 参数中指定的用户帐户的密码。
/fFileName
指定文件名或目录名样式。在指定样式中可以使用通配符“*”。此外,还可使用 ShareName\FileName。
/a
为 Administrators 组而不是当前用户赋予所有权。
/r
对指定目录和子目录中的所有文件执行递归操作。
/d {Y | N}
当前用户没有查看目录内的文件夹的权限时使用的默认提示。使用 Y 获取所有权,使用 N 取消确认提示。
注释
To perform this procedure, you must be a member of the Administrators group on the local computer, or you must have been delegated the appropriate authority. If the computer is joined to a domain, members of the Domain Admins group might be able to perform this procedure. As a security best practice, consider using Run as to perform this procedure.


该命令通常在批处理文件中使用。


Using the /s, /u, and /p command-line options The /u and /p command-line options are available only when you use /s. You must use /p with /u to provide the user's password.


如果不指定 /a,将为当前登录到计算机上的用户赋予所有权。


不支持问号 (?) 和通配符 (*) 混合使用。


如果在安装了另一个 Windows Server 2003 操作系统的计算机上安装 Windows Server 2003 操作系统,然后尝试删除它,则不能删除整个目录。其中一个名为 \Installer 的隐藏目录包含一些锁定的 .msi 和 .ico 文件,必须格式化驱动器才能删除它们。这是因为 Windows Server 2003 操作系统向该文件应用安全属性,以便只有以前安装的 System 帐户可访问这些文件。甚至该计算机的管理员也不能重置这些权限。必须运行 takeown 才能删除这些文件。
 楼主| 发表于 2011-6-17 02:37:30 | 显示全部楼层
不让你沉!
发表于 2011-6-17 02:59:04 | 显示全部楼层
#include <lsasecur.au3>

Local $hToken = _SeOpenProcessToken(-1)
_SeAdjustTokenPriv($hToken, $SE_RESTORE_PRIV)
_SeCloseHandle($hToken)

Local $pTrusteeOwner = _SeLookupAccountName("SYSTEM")
Local $pSecur = _SeInitSecurityDescriptor()
Local $sFilePath = @ScriptDir & "\test.x"

_SeSetSecurityDescriptorOwner($pSecur, $pTrusteeOwner)
If _SeSetFileSecurity($sFilePath, $SE_INFO_OWNER, $pSecur) Then
        MsgBox(48, "OK", "Done.")
Else
        MsgBox(48, "Error", _SeFormatMsg())
EndIf

_SeHeapFree($pSecur)
_SeHeapFree($pTrusteeOwner)


设置指定文件的所有者为SYSTEM用户,需要目标对象的DACL 允许WRITE_OWNER操作。
发表于 2011-6-17 09:10:52 | 显示全部楼层
建议P大有空将那个lsasecur.au3弄几个示例,造福大众啊~~
发表于 2011-6-17 11:22:43 | 显示全部楼层
顶一下,学习
发表于 2011-6-18 21:34:46 | 显示全部楼层
学习了..顶一个
发表于 2011-6-18 21:53:25 | 显示全部楼层
学习了..顶一个
发表于 2011-6-19 00:23:58 | 显示全部楼层
批处理不懂啊。
 楼主| 发表于 2011-6-20 13:28:48 | 显示全部楼层
怎么搞成几解决啊?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-9 18:39 , Processed in 0.105542 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表