Skip to content

Commit 255fc37

Browse files
committed
Shell Extension Handler support
- switched from CMake to MSBuild - bumped version number to 0.2 - updated README
1 parent 1d533a8 commit 255fc37

28 files changed

+1006
-142
lines changed

.github/workflows/cmake.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.github/workflows/msbuild.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
6+
name: MSBuild
7+
8+
on:
9+
workflow_dispatch:
10+
11+
env:
12+
# Path to the solution file relative to the root of the project.
13+
SOLUTION_FILE_PATH: RunAsTI.sln
14+
15+
# Configuration type to build.
16+
# You can convert this to a build matrix if you need coverage of multiple configuration types.
17+
# https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
18+
BUILD_CONFIGURATION: Release
19+
20+
permissions:
21+
contents: read
22+
23+
jobs:
24+
build:
25+
runs-on: windows-latest
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Add MSBuild to PATH
31+
uses: microsoft/setup-msbuild@v1.0.2
32+
33+
- name: Build
34+
working-directory: ${{env.GITHUB_WORKSPACE}}
35+
# Add additional options to the MSBuild command line here (like platform or verbosity level).
36+
# See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
37+
run: msbuild /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}}
38+
39+
- name: Upload
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: assets
43+
path: ${{github.workspace}}/x64/Release

CMakeLists.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.

CMakePresets.json

Lines changed: 0 additions & 61 deletions
This file was deleted.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 mbcdev
3+
Copyright (c) 2023-2024 mbcdev
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,58 @@
11
# RunAsTrustedInstaller
2+
23
A Windows command-line utility to run programs with TrustedInstaller privileges.
34

45
## Description
5-
On Windows, TrustedInstaller privileges sometimes can be helpful to modify/delete criticial system files/folders that are protected by the OS.
6-
Likewise, there might be a need to deal with certain Registry keys that are protected with an ACL which restricts access to the TrustedInstaller account.
6+
7+
On Windows, TrustedInstaller privileges can sometimes be helpful for modifying or deleting criticial system files and folders that are protected by the OS.
8+
Likewise, there may be a need to deal with certain registry keys that are protected by an ACL that restricts access to the TrustedInstaller account.
79
The utility was developed as a standalone executable and does not require any installation.
810

11+
Starting with Release 0.2, a Shell Extension Handler can optionally be installed, which provides an additional **"Run as TrustedInstaller"** context menu entry for `.exe` files in Windows Explorer. Note that both `RunAsTIShellExtension.dll` and `RunAsTI.exe` need to reside in the same directory.
12+
913
## Getting Started
1014

1115
### Compilation
16+
17+
```text
18+
MSBuild RunAsTI.sln
1219
```
13-
cmake .
14-
cmake --build .
15-
```
16-
Alternatively, you can simply open `CMakeLists.txt` in Visual Studio and compile from there.
20+
21+
Alternatively, you can simply open the `RunAsTI.sln` Solution File in Visual Studio and compile from there.
1722

1823
### Usage Examples
1924

2025
Delete a file that cannot be deleted the regular way:
21-
```
26+
27+
```text
2228
RunAsTI.exe cmd.exe /c del C:\Windows\system32\foobar.dat
2329
```
2430

25-
Open the Registry Editor to view/modify/delete Registry keys/values that are not accessible in normal operation mode:
26-
```
31+
Open the Registry Editor to view/modify/delete registry keys/values which are not accessible in normal operation mode:
32+
33+
```text
2734
RunAsTI.exe C:\Windows\regedit.exe
2835
```
2936

37+
Install Shell Extension Handler:
38+
39+
```text
40+
RunAsTI.exe /install
41+
```
42+
43+
Uninstall Shell Extension Handler:
44+
45+
```text
46+
RunAsTI.exe /uninstall
47+
```
48+
3049
## Version History
3150

51+
* 0.2
52+
* Added Shell Extension Handler support
3253
* 0.1
33-
* Initial Release
54+
* Initial Release
3455

3556
## License
36-
This project is licensed under the MIT License.
57+
58+
This project is licensed under the MIT License.

RunAsTI.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <iostream>
2+
#include <Shlwapi.h>
23

34
#include "Utils.h"
45

@@ -12,7 +13,13 @@ int main()
1213

1314
if (lpArgs != NULL)
1415
{
15-
if (nArgs > 1)
16+
if (nArgs == 2 && !_wcsicmp(lpArgs[1], L"/install")) {
17+
ShellExecute(NULL, L"open", L"regsvr32.exe", L"/i RunAsTIShellExtension.dll", NULL, SW_SHOWNORMAL);
18+
}
19+
else if (nArgs == 2 && !_wcsicmp(lpArgs[1], L"/uninstall")) {
20+
ShellExecute(NULL, L"open", L"regsvr32.exe", L"/u RunAsTIShellExtension.dll", NULL, SW_SHOWNORMAL);
21+
}
22+
else if (nArgs > 1)
1623
{
1724
std::wstring cmdApp;
1825
std::wstring cmdArgs;
@@ -25,10 +32,12 @@ int main()
2532
lpCommandLine++;
2633
}
2734

28-
if(nArgs > 2)
35+
if (nArgs > 2) {
2936
std::wcout << "Executing '" << cmdApp.c_str() << "' with args '" << cmdArgs.c_str() << "'..." << std::endl;
30-
else
37+
}
38+
else {
3139
std::wcout << "Executing '" << cmdApp.c_str() << "'..." << std::endl;
40+
}
3241

3342
if (ExecuteCommand(cmdApp, cmdArgs))
3443
{
@@ -40,7 +49,11 @@ int main()
4049
}
4150
}
4251
else {
43-
std::wcout << "Usage: " << *lpArgs << " <cmdline>" << std::endl;
52+
std::wstring exeName = *lpArgs;
53+
PathStripPath(&exeName[0]);
54+
std::wcout << "Usage: " << exeName.c_str() << " <cmdline> Executes <cmdline> with TrustedInstaller privileges." << std::endl;
55+
std::wcout << " " << exeName.c_str() << " /install Installs Shell Extension Handler." << std::endl;
56+
std::wcout << " " << exeName.c_str() << " /uninstall Uninstalls Shell Extension Handler." << std::endl;
4457
}
4558
LocalFree(lpArgs);
4659
}

RunAsTI.rc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ END
5353
//
5454

5555
VS_VERSION_INFO VERSIONINFO
56-
FILEVERSION 0,1,0,0
57-
PRODUCTVERSION 0,1,0,0
56+
FILEVERSION 0,2,0,0
57+
PRODUCTVERSION 0,2,0,0
5858
FILEFLAGSMASK 0x3fL
5959
#ifdef _DEBUG
6060
FILEFLAGS 0x1L
@@ -71,12 +71,12 @@ BEGIN
7171
BEGIN
7272
VALUE "CompanyName", "mbcdev"
7373
VALUE "FileDescription", "RunAsTrustedInstaller"
74-
VALUE "FileVersion", "0.1.0.0"
74+
VALUE "FileVersion", "0.2.0.0"
7575
VALUE "InternalName", "RunAsTI.exe"
76-
VALUE "LegalCopyright", "Copyright (c) 2023 mbcdev"
76+
VALUE "LegalCopyright", "Copyright (c) 2023-2024 mbcdev"
7777
VALUE "OriginalFilename", "RunAsTI.exe"
7878
VALUE "ProductName", "RunAsTrustedInstaller"
79-
VALUE "ProductVersion", "0.1.0.0"
79+
VALUE "ProductVersion", "0.2.0.0"
8080
END
8181
END
8282
BLOCK "VarFileInfo"

RunAsTI.sln

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35506.116 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RunAsTI", "RunAsTI.vcxproj", "{A39C5F40-DD2B-3A32-B8B5-5FD7CA1DF167}"
7+
ProjectSection(ProjectDependencies) = postProject
8+
{4B847C33-2D23-410A-8A48-FBE9F0EEA96E} = {4B847C33-2D23-410A-8A48-FBE9F0EEA96E}
9+
EndProjectSection
10+
EndProject
11+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RunAsTIShellExtension", "ShellExtension\RunAsTIShellExtension.vcxproj", "{4B847C33-2D23-410A-8A48-FBE9F0EEA96E}"
12+
EndProject
13+
Global
14+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
15+
Debug|x64 = Debug|x64
16+
Release|x64 = Release|x64
17+
EndGlobalSection
18+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
19+
{A39C5F40-DD2B-3A32-B8B5-5FD7CA1DF167}.Debug|x64.ActiveCfg = Debug|x64
20+
{A39C5F40-DD2B-3A32-B8B5-5FD7CA1DF167}.Debug|x64.Build.0 = Debug|x64
21+
{A39C5F40-DD2B-3A32-B8B5-5FD7CA1DF167}.Release|x64.ActiveCfg = Release|x64
22+
{A39C5F40-DD2B-3A32-B8B5-5FD7CA1DF167}.Release|x64.Build.0 = Release|x64
23+
{4B847C33-2D23-410A-8A48-FBE9F0EEA96E}.Debug|x64.ActiveCfg = Debug|x64
24+
{4B847C33-2D23-410A-8A48-FBE9F0EEA96E}.Debug|x64.Build.0 = Debug|x64
25+
{4B847C33-2D23-410A-8A48-FBE9F0EEA96E}.Release|x64.ActiveCfg = Release|x64
26+
{4B847C33-2D23-410A-8A48-FBE9F0EEA96E}.Release|x64.Build.0 = Release|x64
27+
EndGlobalSection
28+
GlobalSection(SolutionProperties) = preSolution
29+
HideSolutionNode = FALSE
30+
EndGlobalSection
31+
GlobalSection(ExtensibilityGlobals) = postSolution
32+
SolutionGuid = {4F263B2A-4489-35EE-915B-91872F54CF5C}
33+
EndGlobalSection
34+
EndGlobal

0 commit comments

Comments
 (0)