这是以前大学在纸飞机社区做的东西,其实很简单,只是我把过程整得很复杂,因为当时在学习批处理方面的知识,所以记录下了整个制作。文件分享在下面的网盘里,大家如果要用直接用里面的InstallTakeOwnership.reg文件写入的注册表就可以了。
以下记录的是把reg注册表文件,改成用bat批处理文件,再用Bat_To_Exe_Converter.exe程序把bat批处理文件打包做成可执行程序的过程。
原代码如下
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\runas]
@="Take Ownership"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\*\shell\runas\command]
@="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
[HKEY_CLASSES_ROOT\Directory\shell\runas]
@="Take Ownership"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\shell\runas\command]
@="cmd.exe /c takeown /f \"%1电脑\" /r /d y && icacls \"%1\" /grant administrators:F /t"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"
第一步加工是把它变成BAT的批处理文件
改动代码如下
> "%Temp%.\DefOpen.reg" ECHO Windows Registry Editor Version 5.00
>>"%Temp%.\DefOpen.reg" ECHO.
>>"%Temp%.\DefOpen.reg" ECHO [HKEY_CLASSES_ROOT\*\shell\runas]
>>"%Temp%.\DefOpen.reg" ECHO @="Take Ownership"
>>"%Temp%.\DefOpen.reg" ECHO "NoWorkingDirectory"=""
>>"%Temp%.\DefOpen.reg" ECHO.
>>"%Temp%.\DefOpen.reg" ECHO [HKEY_CLASSES_ROOT\*\shell\runas\command]
>>"%Temp%.\DefOpen.reg" ECHO @="电脑cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
>>"%Temp%.\DefOpen.reg" ECHO "IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
>>"%Temp%.\DefOpen.reg" ECHO.
>>"%Temp%.\DefOpen.reg" ECHO [HKEY_CLASSES_ROOT\Directory\shell\runas]
>>"%Temp%.\DefOpen.reg" ECHO @="Take Ownership"
>>"%Temp%.\DefOpen.reg" ECHO "NoWorkingDirectory"=""
>>"%Temp%.\DefOpen.reg" ECHO.
>>"%Temp%.\DefOpen.reg" ECHO [HKEY_CLASSES_ROOT\Directory\shell\runas\command]
>>"%Temp%.\DefOpen.reg" ECHO @="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\电脑34; /grant administrators:F /t"
>>"%Temp%.\DefOpen.reg" ECHO "IsolatedCommand"="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"
START /WAIT REGEDIT /S "%Temp%.\DefOpen.reg"
DEL "%Temp%.\DefOpen.reg"
再接下来,就是把这个批处理做个漂亮的修饰
@echo off
cd\
cls
color 4a
mode con cols=80 lines=40
echo ■───────────────────────────────────── ■
echo.■ ☆ ★ 纸飞机系统批处理工具集 ★ ☆ ■
echo ■ ■
echo ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※
echo ■ win7系统去权限工具,安装后会在右键对话框多出一个take ownership的选 ■
echo ■ 项,在任意你想去除系统管理员权限的文件上点右键,选择take ownership即可去 ■
echo ■ 除该文件的系统管理员权限,再也不用担心无管理员权限而删不了文件,无法重命 ■
echo ■ 名文件等情况了.按任意键开始安装 ■
pause
> "%Temp%.\DefOpen.reg" ECHO Windows Registry Editor Version 5.00
>>"%Temp%.\DefOpen.reg" ECHO.
>>"%Temp%.\DefOpen.reg" ECHO [HKEY_CLASSES_ROOT\*\shell\runas]
>>"%Temp%.\DefOpen.reg" ECHO @="Take Ownership"
>>"%Temp%.\DefOpen.reg" ECHO "NoWorkingDirectory"=""
>>"%Temp%.\DefOpen.reg" ECHO.
>>"%Temp%.\DefOpen.reg" ECHO [HKEY_CLASSES_ROOT\*\shell\runas\command]
>>"%Temp%.\DefOpen.reg" ECHO @="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
>>"%Temp%.\DefOpen.reg" ECHO "IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
>>"%Temp%.\DefOpen.reg" ECHO.
>>"%Temp%.\DefOpen.reg" ECHO [HKEY_CLASSES_ROOT\Directory\shell\runas]
>>"%Temp%.\DefOpen.reg" ECHO @="Take Ownership"
>>"%Temp%.\DefOpen.reg" ECHO "NoWorkingDirectory"=""
>>"%Temp%.\DefOpen.reg" ECHO.
>>"%Temp%.\DefOpen.reg" ECHO [HKEY_CLASSES_ROOT\Directory\shell\runas\command]
>>"%Temp%.\DefOpen.reg" ECHO @="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"
>>"%Temp%.\DefOpen.reg" ECHO "IsolatedCommand"="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"
START /WAIT REGEDIT /S "%Temp%.\DefOpen.reg"
DEL "%Temp%.\DefOpen.reg"
最后把这个批处理文件用Bat_To_Exe_Converter.exe这个软件变成可执行文件,就是下面这个小熊图标的程序。
所有文件打包网盘分享,另外注意下载的电脑如果有杀毒软件或防护软件会认为里面有病毒,那是因为批处理以及里面指令特性的原因,不用担心
http://pan.baidu.com/share/link?shareid=3031728165&uk=1997478744
电脑