-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path05-ProcessUnifiedAuditLogFlatten.bat
60 lines (48 loc) · 2.29 KB
/
05-ProcessUnifiedAuditLogFlatten.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
:: Bitpusher
:: \`._,'/
:: (_- -_)
:: \o/
:: The Digital
:: Fox
:: @VinceVulpes
:: https://theTechRelay.com
:: https://github.com/bitpusher2k
::
:: DropShim.bat - By Bitpusher/The Digital Fox
::
:: v2.0 last updated 2024-01-19
:: BAT-to-PS shim script allowing drag-and-drop of files to pass to PS script for processing.
::
:: Rename this BAT to be the same name as the PS1 script that you want to run, and place this BAT in same directory as PS1 script.
:: Drag-and-drop a file onto this BAT to run the similarly named PS1 and pass the dropped file path(s) as parameter(s).
:: Can handle spaces in the path to PS script, in the path to drag-and-drop file, and in the name of the files themselves.
::
:: Can also just double-click the BAT to run PS1 script of the same name in current directory with no parameters.
::
:: #psshim #powershell #shim #wrapper #powershell #bat #drag-and-drop
:: Argument is the full path to the file that was drag-and-dropped onto this bat:
@SET args=%1
:: @echo ARGS: %args%
:: Path is the drive path to this bat script that also has the similarly named PS1 script next to it:
@SET path=%~dp0
:: @echo PATH: %path%
:: Script name is the same as the BAT name, but with ".ps1" extension:
@SET script=%~n0.ps1
:: @echo SCRIPT: %script%
:More
@SHIFT
@IF '%1' == '' GOTO Done
@SET args=%args%,'%1'
@GOTO More
:Done
:: Run with same permissions as current user the conservative way - change to directory of script and run from there:
:: @CD "%path%"
:: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noprofile -command ".\%script% '%args%'"
:: Another way to run with same permissions as current user (direct through drive-path-name variable):
C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '%path%%script%' '%args%'"
:: If PowerShell is in your path you can remove the full directory location:
:: PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%path%%script%' '%args%'"
:: Run script as admin:
:: C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -NoProfile -ExecutionPolicy Bypass -Command "Start-Process -Verb RunAs powershell -ArgumentList '-NoExit -NoProfile -ExecutionPolicy Bypass -File \"%path%%script%\" \"%args%\"'"
@echo.
@pause