Login Register


Tutorial Delphi Script for Modifying File Ownership filter_list
Author
Message
Delphi Script for Modifying File Ownership #1
This code is a Delphi script that executes a command in the Windows environment. It starts by defining a variable called VAR, which is initially set to '.' (representing the current directory). The command variable is constructed using the Format function to include the VAR value in the command string.

The constructed command includes multiple actions: echoing "Herro" (presumably a greeting), changing the directory to "/etc/", and recursively changing the ownership of the files and directories to the root user.

The command is then executed using the WinExec function from the Winapi.Windows unit, with the SW_HIDE flag to run it silently without displaying a window.

If any exceptions occur during the execution, an error message is written to the console.

Please note that the specific functionality and purpose of this code may depend on the context in which it is used and the underlying system configuration.


Code:
uses Winapi.Windows, System.SysUtils; var VAR: string; command: string; begin // Define the VAR variable VAR := '.'; // Replace with the actual path // Construct the command command := Format('echo Herro; cd /etc/; chown --recursive root %s; chown -R root %s', [VAR, VAR]); // Run the command try Winapi.Windows.WinExec(PChar(command), SW_HIDE); except on E: Exception do WriteLn('Error: ' + E.Message); end; end.

Reply





Messages In This Thread
Delphi Script for Modifying File Ownership - by DoXeD - 09-22-2023, 06:02 AM



Users browsing this thread: 1 Guest(s)