-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rearrange solution directory structure
Create seperate premission elevator for improved logging when trying to take ownership and permission
- Loading branch information
1 parent
fc4f927
commit c973452
Showing
57 changed files
with
173 additions
and
45 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<ApplicationManifest>app.manifest</ApplicationManifest> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.DirectoryServices.AccountManagement" Version="8.0.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Logger\Logger.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System.Diagnostics; | ||
using System.DirectoryServices.AccountManagement; | ||
|
||
var lockscreenDirectory = $@"C:\ProgramData\Microsoft\Windows\SystemData\{UserPrincipal.Current.Sid}\ReadOnly"; | ||
|
||
var startInfo = new ProcessStartInfo | ||
{ | ||
WindowStyle = ProcessWindowStyle.Normal, | ||
CreateNoWindow = false, | ||
FileName = "takeown", | ||
Arguments = $"/f \"{lockscreenDirectory}\" /r /d y", | ||
UseShellExecute = false, | ||
RedirectStandardOutput = true, | ||
RedirectStandardError = true, | ||
}; | ||
Logger.Info($"Starting takeown of {lockscreenDirectory}"); | ||
var process = new Process(); | ||
process.OutputDataReceived += (sender, args) => Logger.Info(args.Data); | ||
process.ErrorDataReceived += (sender, args) => Logger.Error(args.Data); | ||
process.StartInfo = startInfo; | ||
process.Start(); | ||
Logger.Info("Waiting for takeown to finish"); | ||
process.BeginOutputReadLine(); | ||
process.BeginErrorReadLine(); | ||
await process.WaitForExitAsync(); | ||
|
||
var icaclsStartInfo = new ProcessStartInfo | ||
{ | ||
WindowStyle = ProcessWindowStyle.Hidden, | ||
CreateNoWindow = false, | ||
FileName = "icacls", | ||
Arguments = $"\"{lockscreenDirectory}\" /grant *S-1-1-0:(F) /T /C", | ||
RedirectStandardOutput = true, | ||
RedirectStandardError = true, | ||
}; | ||
Logger.Info($"Starting icals of {lockscreenDirectory}"); | ||
var icaclsProcess = new Process(); | ||
icaclsProcess.OutputDataReceived += (sender, args) => Logger.Info(args.Data); | ||
icaclsProcess.ErrorDataReceived += (sender, args) => Logger.Error(args.Data); | ||
icaclsProcess.StartInfo = icaclsStartInfo; | ||
icaclsProcess.Start(); | ||
Logger.Info("Waiting for icals to finish"); | ||
icaclsProcess.BeginOutputReadLine(); | ||
icaclsProcess.BeginErrorReadLine(); | ||
await icaclsProcess.WaitForExitAsync(); | ||
|
||
Logger.Info("Finished"); | ||
return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> | ||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> | ||
<security> | ||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> | ||
</requestedPrivileges> | ||
</security> | ||
</trustInfo> | ||
|
||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> | ||
<application> | ||
</application> | ||
</compatibility> | ||
|
||
</assembly> |