我在批量编写的程序上有一个插件系统,如下所示; (感谢https://stackoverflow.com/users/3536342/davidpostill)
:plugindragon
echo.
echo Plugins
echo ==============
dir /b plugins\*.cmd
echo.
echo Enter the name of the plugin you want to run.
set /p plugin=root/plugins/plugin_dragon.jr@Root:~$
start "" plugins\%plugin%
goto root
有没有办法阻止我的程序用户在不运行pluginDragon脚本的情况下打开所说的插件?因为他们不能直接进入插件文件夹并双击应用程序(因为它们都是批量编写的)。他们需要使用"终端"打开它们的窗口,只有那个。
答案 0 :(得分:0)
以下是对脚本的修改,执行以下操作:
attrib
使用icacls
更改文件的权限,使其无法打开
:plugindragon
echo.
echo Plugins
echo ==============
dir /b plugins\*.cmd
echo.
echo Enter the name of the plugin you want to run (Exclude extension).
set /p plugin=root/plugins/plugin_dragon.jr@Root:~$
:: Grant permission to access file
icacls "plugins\%plugin%.cmd" /grant everyone:F /T /C /Q>nul 2>&1
:: Unhide the file
attrib -h -s -r -a "plugins\%plugin%.cmd" >nul
start /wait "" plugins\%plugin%.cmd
:: Hide the file
attrib +h +s +r +a "plugins\%plugin%.cmd" >nul
:: Denies access to the file
icacls "plugins\%plugin%.cmd" /deny everyone:F /T /C /Q>nul 2>&1
goto root