Skip to content

Commit 29c2a85

Browse files
committed
FileActionsManager v1.0
0 parents  commit 29c2a85

18 files changed

+1406
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.suo
2+
Other
3+
FileActionsConsole/bin
4+
FileActionsConsole/obj
5+
FileActionsConsole/*.user
6+
FileActionsManager/bin
7+
FileActionsManager/obj
8+
FileActionsManager/*.user
9+
.vs
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{9E2133B2-F1E4-4BDD-B105-1797C8F703F5}</ProjectGuid>
9+
<OutputType>Exe</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>FileActionsConsole</RootNamespace>
12+
<AssemblyName>FileActionsConsole</AssemblyName>
13+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14+
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
15+
<FileAlignment>512</FileAlignment>
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
18+
<PlatformTarget>x86</PlatformTarget>
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
28+
<PlatformTarget>x86</PlatformTarget>
29+
<DebugType>pdbonly</DebugType>
30+
<Optimize>true</Optimize>
31+
<OutputPath>bin\Release\</OutputPath>
32+
<DefineConstants>TRACE</DefineConstants>
33+
<ErrorReport>prompt</ErrorReport>
34+
<WarningLevel>4</WarningLevel>
35+
</PropertyGroup>
36+
<ItemGroup>
37+
<Reference Include="System" />
38+
<Reference Include="System.Core" />
39+
<Reference Include="System.Xml.Linq" />
40+
<Reference Include="System.Data.DataSetExtensions" />
41+
<Reference Include="Microsoft.CSharp" />
42+
<Reference Include="System.Data" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="Program.cs" />
47+
<Compile Include="Properties\AssemblyInfo.cs" />
48+
<Compile Include="ShellFileType.cs" />
49+
</ItemGroup>
50+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
51+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
52+
Other similar extension points exist, see Microsoft.Common.targets.
53+
<Target Name="BeforeBuild">
54+
</Target>
55+
<Target Name="AfterBuild">
56+
</Target>
57+
-->
58+
</Project>

FileActionsConsole/Program.cs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Diagnostics;
6+
using System.IO;
7+
using SharpTools;
8+
9+
namespace FileActionsConsole
10+
{
11+
/// <summary>
12+
/// Command-line utility for creating/deleting file context menu actions
13+
/// By ORelio - (c) 2015-2018 - Available under the CDDL-1.0 license
14+
/// </summary>
15+
class Program
16+
{
17+
static void Main(string[] args)
18+
{
19+
try
20+
{
21+
//ShellFileType.AddAction("txt", "testaction", "Testing FileActionsManager", "cmd.exe /C echo %1 && pause > nul");
22+
//ShellFileType.RemoveAction("txt", "testaction");
23+
24+
if (args.Length == 3 && args[0] == "del")
25+
{
26+
ShellFileType.RemoveAction(args[1].Split(','), args[2]);
27+
}
28+
else if ((args.Length == 5 || args.Length == 6) && args[0] == "add")
29+
{
30+
ShellFileType.AddAction(args[1].Split(','), args[2], args[3], args[4], args.Length == 6 && args[5] == "default");
31+
}
32+
else
33+
{
34+
string exeName = Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName);
35+
Console.WriteLine(" - Windows Shell Menu Action Setter v1.0 - By ORelio -\n");
36+
Console.WriteLine("Usage: " + exeName + " add <ext> <int> <dsp> <cmd> [def]");
37+
Console.WriteLine("Usage: " + exeName + " del <ext> <int>\n");
38+
Console.WriteLine("add : Add or update the action based on internal name");
39+
Console.WriteLine("del : Remove the action based on internal name");
40+
Console.WriteLine("ext : List of file extensions to affect eg mp3 or mp3,mp4 and so on");
41+
Console.WriteLine("int : internal name to designate the action");
42+
Console.WriteLine("dsp : display name of the shell menu item");
43+
Console.WriteLine("cmd : command to execute when selecting item. File is provided as %1");
44+
Console.WriteLine("def : add `default' as last argument for setting the action as the default one");
45+
}
46+
}
47+
catch (UnauthorizedAccessException)
48+
{
49+
RelaunchAsAdmin(args, true);
50+
}
51+
}
52+
53+
public static void RelaunchAsAdmin(string[] args, bool waitforexit = false)
54+
{
55+
ProcessStartInfo startInfo = new ProcessStartInfo();
56+
57+
startInfo.Verb = "runas";
58+
startInfo.Arguments = String.Join(" ", args.Select(arg => "\"" + args + '"').ToArray());
59+
startInfo.FileName = Process.GetCurrentProcess().MainModule.FileName;
60+
61+
Process process = Process.Start(startInfo);
62+
63+
if (waitforexit)
64+
process.WaitForExit();
65+
}
66+
}
67+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("FileActionsManager")]
9+
[assembly: AssemblyDescription("Manage shell menu items through command line")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("By ORelio - Microzoom.fr")]
12+
[assembly: AssemblyProduct("File Actions Console")]
13+
[assembly: AssemblyCopyright("Copyright © ORelio 2015-2018")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("edecdee5-b0d2-46a1-902d-7506c2610be7")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)