How to delete subfolders and Files but not parent Folder in windows using Script? [closed]

As PowerShell supports wildcards/patterns on multiple levels of a path, it’s as simple as: Get-ChildItem D:\test[1-3]\* | Remove-Item -Recurse -Force Sample tree before and after running the command: > tree /F D:. ├───test1 │ └───test1 │ └───archive │ x.txt │ ├───test2 │ └───try │ └───archive │ x.txt │ └───test3 └───model └───archive x.txt > Get-ChildItem D:\test[1-3]\*|Remove-Item … Read more

Batch file v PowerShell script

The following code executes the same code via both processes: internal class Program { private static void Main() { const string COMMAND = @”SCHTASKS /QUERY /XML ONE”; Collection<PSObject> psObjects; using (var ps = PowerShell.Create()) { ps.AddScript(COMMAND); psObjects = ps.Invoke(); } var process = new Process { StartInfo = new ProcessStartInfo { UseShellExecute = false, RedirectStandardOutput … Read more

DLLImport of the origin function in the DLL

If only kernel32.dll is being changed you could call ntdll.dll!NtReadVirtualMemory (ReadProcessMemory itself calls this function). If ntdll.dll is also seems to be changed by 3rd party process you could copy ntdll.dll to another temporary file (ntdll_copy.dll), and use it: [DllImport(“ntdll_copy.dll”, EntryPoint = “NtReadVirtualMemory”)] private static extern bool NtReadVirtualMemory(IntPtr hProcess, UIntPtr lpBaseAddress, [Out] byte[] lpBuffer, UIntPtr … Read more