Get the App
SLTechnology News&Howtos  ›  Servers  › 

Advanced commands in bat batch configuration of icacls permissions

Shulou Source: shulou.com Published: 2022-06-03 02:16:58 10月02日 Update

Only you can't think of it, it's not impossible, it's just that you can't get through the way of thinking in your world for the time being; personally, you can't judge whether a language is powerful or not unilaterally, that's because you don't know it well enough, and you don't have a complete grasp of the essence.

Any language has its advantages in development, but we need to compromise and choose, things need to be chosen, our minds diverge, and things (things) communicate with each other as much as possible. Sometimes we do not understand many things for the time being, fall into a bottleneck, through a period of exploration and practice (not limited to this thing), we suddenly find that we have understood the wonderful things, the wonders of the world, the wonders of the world, and even a thousand ideas, but at some point we begin to form a line.

After talking so much, saying a truth seems to be nonsense. I digest it by myself. I haven't written a BAT command for a long time. Let's get to the topic and do a BAT demonstration. There is a batch code on the so-and-so server. Now you need to clean up the * (replace the file specified in the server config.php) in the file. In order to prevent this situation from recurring, write this file is prohibited. In this case, the entire scene of the case is reproduced with BAT at 1:1.

Site creation:

:: Author: jerry

@ echo off

Set pathwww= "E:\ wwwroot"

For / f% I in (web.txt) do (

Echo I

Mkdir% pathwww%\% I\ web > > log.txt

)

Echo. & pause

Site list

Create a list of effects

Data replication and replacement (note directory change):

:: Author: jerry

@ echo off

Set pathwww= "E:\ wwwroot"

For / f% I in (web.txt) do (

Echo I

Xcopy "E:\ bak\ web\% i.rar" / k "E:\ bak\ new\" / y > log.txt

)

Echo. & pause

Build site users in batches:

:: Author: jerry

@ echo off

Set pathwww= "E:\ wwwroot"

For / f% I in (web.txt) do (

Echo I

Net user I / add > > userlog.txt

)

Echo. & pause

View the user created under: net user

Volume Licensing:

Display before the site file is not authorized:

Volume Licensing script:

@ echo off

:: author: by jerry

Set pathwww= "E:\ wwwroot"

For / f "usebackq tokens=1 delims="% an in (web.txt) do call: qx% a

Pause

: qx

Set webname=%1%

Icacls% pathwww%\% webname%\ web\ config.php / grant% webname%: (rx) > > chmod.log

Icacls pathwww%\% webname%\ web\ config.php / deny% webname%: (w) > > chmod.log

Echo. & pause

Demonstrate the completion of cleaning account information, clean up site script:

:: Author: jerry

@ echo off

Set pathwww= "E:\ wwwroot"

For / f% I in (web.txt) do (

Echo I

Net user I / delete > > dellog.txt

Rd% pathwww%\% I / Q / s

)

Echo. & pause

The content has also been cleaned up:

The case is demonstrated with code at 1:1 around the entire life cycle from site directory creation, data replication (override), site user creation, permission configuration, permission change, to site account and overall site deletion. At the end of the whole operation, I talked about a lot of key points: icacls, a convenient advanced cargo command application, which is usually a little bit and seldom used.

Tags: Site thing file case user presentation command permission wonderful world just data server directory script language account service configuration powerful Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Docker Shulou Information Xiaomi Huawei