Skip to content

Commit 232edcc

Browse files
authored
Merge branch 'corpnewt:master' into master
2 parents 9b1ca61 + a38a9b2 commit 232edcc

File tree

4 files changed

+175
-42
lines changed

4 files changed

+175
-42
lines changed

ProperTree.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,14 @@ def convert_values(self, event = None):
12141214
self.f_text.delete(0,tk.END)
12151215
self.f_text.insert(0,from_value)
12161216
from_value = base64.b64decode(self.get_bytes(from_value))
1217-
elif from_type in ["hex","decimal"]:
1217+
elif from_type in ("hex","decimal"):
1218+
if len(from_value) % 2:
1219+
# Ensure we pad our hex
1220+
from_value = "0"+from_value
1221+
# Reflect it visually for all cases that need it
1222+
if to_type not in ("hex","decimal"):
1223+
self.f_text.delete(0,tk.END)
1224+
self.f_text.insert(0,from_value)
12181225
from_value = binascii.unhexlify(self.get_bytes(from_value))
12191226
# Let's get the data converted
12201227
to_value = self.get_bytes(from_value)

ProperTreeQuiet.bat

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<!-- : Begin batch script
2+
3+
@echo off
4+
set "script_name=%~n0"
5+
REM Check if we have "Quiet" at the end of our name
6+
if /i not "%script_name:~-5%" == "quiet" (
7+
echo This script is intended to be a quiet version of the target
8+
echo script, however its name does not end in "quiet" so the target
9+
echo script cannot be located.
10+
echo.
11+
echo Press [enter] to quit.
12+
pause > nul
13+
exit /b
14+
)
15+
set "target_name=%script_name:~0,-5%.bat"
16+
if not exist "%~dp0%target_name%" (
17+
echo Could not find %target_name%.
18+
echo Please make sure to run this script from the same directory
19+
echo as %target_name%.
20+
echo.
21+
echo Press [enter] to quit.
22+
pause > nul
23+
exit /b
24+
)
25+
cscript //nologo "%~f0?.wsf" //job:QUIET "%~dp0%target_name%" %*
26+
exit /b
27+
28+
----- Begin wsf script --->
29+
30+
<package>
31+
<job id="QUIET">
32+
<script language="VBScript">
33+
dim self_path: self_path = WScript.ScriptFullName
34+
If StrComp(Right(self_path,5),"?.wsf",vbTextCompare)=0 Then: self_path = Left(self_path,Len(self_path)-5): End If
35+
Set argument_list = CreateObject("System.Collections.ArrayList")
36+
For Each argument_item in WScript.Arguments
37+
If StrComp(argument_item,"--self",vbTextCompare)=0 Then: argument_item = self_path: End If
38+
Call argument_list.Add(argument_item)
39+
Next
40+
If argument_list.Count=0 Then: Call argument_list.Add(self_path): End If
41+
For Each a in argument_list
42+
If args<>"" Then: args = args & " ": End If
43+
args = args & chr(34) & a & chr(34)
44+
Next
45+
CreateObject("Wscript.Shell").Run args, 0, False
46+
</script>
47+
</job>
48+
</package>

Scripts/AssociatePlistFiles.bat

+62-23
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,91 @@
1+
<!-- : Begin batch script
2+
13
@echo off
4+
setlocal enableDelayedExpansion
25

36
:checkPrivileges
4-
NET FILE 1>NUL 2>NUL
5-
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
7+
net file 1>nul 2>nul
8+
if "%errorlevel%" == "0" ( goto gotPrivileges ) else ( goto getPrivileges )
69

710
:getPrivileges
8-
if '%~1'=='ELEV' (shift & goto main)
9-
ECHO.
10-
11-
setlocal DisableDelayedExpansion
12-
set "batchPath=%~0"
13-
setlocal EnableDelayedExpansion
14-
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs"
15-
ECHO UAC.ShellExecute "!batchPath!", "ELEV", "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs"
16-
"%temp%\OEgetPrivileges.vbs"
17-
exit /B
11+
cscript //nologo "%~f0?.wsf" //job:ADMIN "--self" %*
12+
exit /b
1813

1914
:gotPrivileges
20-
@echo off
21-
setlocal enableDelayedExpansion
2215
cls
16+
REM See if we have a custom script passed
17+
set "target=ProperTree.bat"
18+
set "name=ProperTree"
19+
if NOT "%~1" == "" (
20+
set "target=%~nx1"
21+
set "name=%~n1"
22+
)
2323
REM Get one directory up
2424
pushd %~dp0
2525
cd ..\
26+
REM Ensure the target exists
27+
if NOT EXIST "%target%" (
28+
echo Could not find %target%.
29+
echo Please make sure to run this script from ProperTree's Scripts Folder.
30+
echo.
31+
echo Press [enter] to quit.
32+
pause > nul
33+
exit /b
34+
)
2635
set "path=%cd%"
2736
set "regpath=%ComSpec:cmd.exe=%reg.exe"
2837
popd
29-
echo Checking if ProperTree.bat exists in registry...
30-
"!regpath!" query "HKCR\Applications\ProperTree.bat" > nul 2>&1
38+
echo Checking if %target% exists in registry...
39+
"!regpath!" query "HKCR\Applications\%target%" > nul 2>&1
3140
if "%errorlevel%"=="0" (
3241
echo - Already exists. Removing...
3342
echo.
34-
"!regpath!" delete "HKCR\Applications\ProperTree.bat" /f 2> nul
43+
"!regpath!" delete "HKCR\Applications\%target%" /f 2> nul
3544
"!regpath!" delete "HKCR\.plist_auto_file" /f 2> nul
3645
"!regpath!" delete "HKCR\.plist" /f 2> nul
37-
"!regpath!" delete "HKCU\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" /v "Applications\ProperTree.bat_.plist" /f 2> nul
46+
"!regpath!" delete "HKCU\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" /v "Applications\%target%_.plist" /f 2> nul
3847
)
39-
set arg=\"%path%\ProperTree.bat\" \"%%1\"
48+
set arg=\"%path%\%target%\" \"%%1\"
4049
echo.
4150
echo Adding registry values...
4251
echo.
43-
"!regpath!" add "HKCR\Applications\ProperTree.bat\shell\Open" /t REG_SZ /d "Open with ProperTree" /f
44-
"!regpath!" add "HKCR\Applications\ProperTree.bat\shell\Open\command" /t REG_SZ /d "%arg%" /f
52+
"!regpath!" add "HKCR\Applications\%target%\shell\Open" /t REG_SZ /d "Open with %name%" /f
53+
"!regpath!" add "HKCR\Applications\%target%\shell\Open\command" /t REG_SZ /d "%arg%" /f
4554
"!regpath!" add "HKCR\.plist" /t REG_SZ /d ".plist_auto_file" /f
46-
"!regpath!" add "HKCR\.plist_auto_file\shell\Open" /t REG_SZ /d "Open with ProperTree" /f
55+
"!regpath!" add "HKCR\.plist_auto_file\shell\Open" /t REG_SZ /d "Open with %name%" /f
4756
"!regpath!" add "HKCR\.plist_auto_file\shell\Open\command" /t REG_SZ /d "%arg%" /f
48-
"!regpath!" add "HKCU\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" /v "Applications\ProperTree.bat_.plist" /t REG_DWORD /d 0 /f
57+
"!regpath!" add "HKCU\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" /v "Applications\%target%_.plist" /t REG_DWORD /d 0 /f
4958
echo.
5059
echo Press [enter] to exit...
5160
pause > nul
5261
exit /b
62+
63+
----- Begin wsf script --->
64+
65+
<package>
66+
<job id="ADMIN">
67+
<script language="VBScript">
68+
dim self_path: self_path = WScript.ScriptFullName
69+
If StrComp(Right(self_path,5),"?.wsf",vbTextCompare)=0 Then: self_path = Left(self_path,Len(self_path)-5): End If
70+
Set argument_list = CreateObject("System.Collections.ArrayList")
71+
For Each argument_item in WScript.Arguments
72+
If StrComp(argument_item,"--self",vbTextCompare)=0 Then: argument_item = self_path: End If
73+
Call argument_list.Add(argument_item)
74+
Next
75+
If argument_list.Count=0 Then: Call argument_list.Add(self_path): End If
76+
dim target_exe: target_exe = "cmd.exe"
77+
If StrComp(Right(argument_list(0),4),".exe",vbTextCompare)=0 Then
78+
target_exe = argument_list(0)
79+
Call argument_list.RemoveAt(0)
80+
ElseIf StrComp(Right(argument_list(0),4),".bat",vbTextCompare)=0 or StrComp(Right(argument_list(0),4),".cmd",vbTextCompare)=0 Then
81+
Call argument_list.Insert(0,"/c")
82+
End If
83+
dim args: args = ""
84+
For Each a in argument_list
85+
if args<>"" Then: args = args & " ": End If
86+
args = args & chr(34) & a & chr(34)
87+
Next
88+
CreateObject("Shell.Application").ShellExecute target_exe, args, , "runas", 5
89+
</script>
90+
</job>
91+
</package>
+57-18
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,81 @@
1+
<!-- : Begin batch script
2+
13
@echo off
4+
setlocal enableDelayedExpansion
25

36
:checkPrivileges
4-
NET FILE 1>NUL 2>NUL
5-
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
7+
net file 1>nul 2>nul
8+
if "%errorlevel%" == "0" ( goto gotPrivileges ) else ( goto getPrivileges )
69

710
:getPrivileges
8-
if '%~1'=='ELEV' (shift & goto main)
9-
ECHO.
10-
11-
setlocal DisableDelayedExpansion
12-
set "batchPath=%~0"
13-
setlocal EnableDelayedExpansion
14-
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs"
15-
ECHO UAC.ShellExecute "!batchPath!", "ELEV", "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs"
16-
"%temp%\OEgetPrivileges.vbs"
17-
exit /B
11+
cscript //nologo "%~f0?.wsf" //job:ADMIN "--self" %*
12+
exit /b
1813

1914
:gotPrivileges
20-
@echo off
21-
setlocal enableDelayedExpansion
2215
cls
16+
REM See if we have a custom script passed
17+
set "target=ProperTree.bat"
18+
set "name=ProperTree"
19+
if NOT "%~1" == "" (
20+
set "target=%~nx1"
21+
set "name=%~n1"
22+
)
2323
REM Get one directory up
2424
pushd %~dp0
2525
cd ..\
26+
REM Ensure the target exists
27+
if NOT EXIST "%target%" (
28+
echo Could not find %target%.
29+
echo Please make sure to run this script from ProperTree's Scripts Folder.
30+
echo.
31+
echo Press [enter] to quit.
32+
pause > nul
33+
exit /b
34+
)
2635
set "path=%cd%"
2736
set "regpath=%ComSpec:cmd.exe=%reg.exe"
2837
popd
29-
echo Checking if ProperTree.bat exists in registry...
30-
"!regpath!" query "HKCR\Applications\ProperTree.bat" > nul 2>&1
38+
echo Checking if %target% exists in registry...
39+
"!regpath!" query "HKCR\Applications\%target%" > nul 2>&1
3140
if "%errorlevel%"=="0" (
3241
echo - Removing registry values...
3342
echo.
34-
"!regpath!" delete "HKCR\Applications\ProperTree.bat" /f 2> nul
43+
"!regpath!" delete "HKCR\Applications\%target%" /f 2> nul
3544
"!regpath!" delete "HKCR\.plist_auto_file" /f 2> nul
3645
"!regpath!" delete "HKCR\.plist" /f 2> nul
37-
"!regpath!" delete "HKCU\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" /v "Applications\ProperTree.bat_.plist" /f 2> nul
46+
"!regpath!" delete "HKCU\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" /v "Applications\%target%_.plist" /f 2> nul
3847
)
3948
echo.
4049
echo Press [enter] to exit...
4150
pause > nul
4251
exit /b
52+
53+
----- Begin wsf script --->
54+
55+
<package>
56+
<job id="ADMIN">
57+
<script language="VBScript">
58+
dim self_path: self_path = WScript.ScriptFullName
59+
If StrComp(Right(self_path,5),"?.wsf",vbTextCompare)=0 Then: self_path = Left(self_path,Len(self_path)-5): End If
60+
Set argument_list = CreateObject("System.Collections.ArrayList")
61+
For Each argument_item in WScript.Arguments
62+
If StrComp(argument_item,"--self",vbTextCompare)=0 Then: argument_item = self_path: End If
63+
Call argument_list.Add(argument_item)
64+
Next
65+
If argument_list.Count=0 Then: Call argument_list.Add(self_path): End If
66+
dim target_exe: target_exe = "cmd.exe"
67+
If StrComp(Right(argument_list(0),4),".exe",vbTextCompare)=0 Then
68+
target_exe = argument_list(0)
69+
Call argument_list.RemoveAt(0)
70+
ElseIf StrComp(Right(argument_list(0),4),".bat",vbTextCompare)=0 or StrComp(Right(argument_list(0),4),".cmd",vbTextCompare)=0 Then
71+
Call argument_list.Insert(0,"/c")
72+
End If
73+
dim args: args = ""
74+
For Each a in argument_list
75+
if args<>"" Then: args = args & " ": End If
76+
args = args & chr(34) & a & chr(34)
77+
Next
78+
CreateObject("Shell.Application").ShellExecute target_exe, args, , "runas", 5
79+
</script>
80+
</job>
81+
</package>

0 commit comments

Comments
 (0)