added the option to create a start menu shortcut
This commit is contained in:
parent
10413acf54
commit
61ab7f0c79
5 changed files with 93 additions and 12 deletions
|
@ -61,6 +61,14 @@
|
||||||
Height="25"
|
Height="25"
|
||||||
Click="CheckForUpdateBtn_OnClick"
|
Click="CheckForUpdateBtn_OnClick"
|
||||||
Margin="4,10,4,0"/>
|
Margin="4,10,4,0"/>
|
||||||
|
|
||||||
|
<Button Name="createShortcut"
|
||||||
|
Style="{StaticResource UniversalMaterialButton}"
|
||||||
|
Content="Create Startmenu Entry"
|
||||||
|
Background="#353340"
|
||||||
|
Height="25"
|
||||||
|
Click="CreateShortcut_OnClick"
|
||||||
|
Margin="4,10,4,0"/>
|
||||||
|
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
|
@ -297,5 +297,19 @@ namespace WeeXnes.MVVM.View
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CreateShortcut_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Process p = Process.Start("WeeXnes_UAC.exe", "-CreateStartMenuShortcut");
|
||||||
|
p.WaitForExit();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Misc.Message message = new Misc.Message(ex.ToString());
|
||||||
|
message.Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using IWshRuntimeLibrary;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
using Application = System.Windows.Forms.Application;
|
||||||
|
|
||||||
namespace WeeXnes_UAC
|
namespace WeeXnes_UAC
|
||||||
{
|
{
|
||||||
|
@ -25,6 +28,11 @@ namespace WeeXnes_UAC
|
||||||
{
|
{
|
||||||
disableAutostart();
|
disableAutostart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (e.Args[i] == "-CreateStartMenuShortcut")
|
||||||
|
{
|
||||||
|
AddShortcut();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -32,7 +40,28 @@ namespace WeeXnes_UAC
|
||||||
MessageBox.Show("No Arguments");
|
MessageBox.Show("No Arguments");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private static void AddShortcut()
|
||||||
|
{
|
||||||
|
|
||||||
|
string path = Application.StartupPath;
|
||||||
|
string fileName = "WeeXnes.exe";
|
||||||
|
string pathToExe = path + "\\" + fileName;
|
||||||
|
string commonStartMenuPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartMenu);
|
||||||
|
Console.WriteLine(commonStartMenuPath);
|
||||||
|
string appStartMenuPath = Path.Combine(commonStartMenuPath, "Programs", "WeeXnes");
|
||||||
|
|
||||||
|
if (!Directory.Exists(appStartMenuPath))
|
||||||
|
Directory.CreateDirectory(appStartMenuPath);
|
||||||
|
|
||||||
|
string shortcutLocation = Path.Combine(appStartMenuPath, "WeeXnes Suite" + ".lnk");
|
||||||
|
WshShell shell = new WshShell();
|
||||||
|
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutLocation);
|
||||||
|
|
||||||
|
shortcut.Description = "WeeXnes Tool Suite";
|
||||||
|
//shortcut.IconLocation = @"C:\Program Files (x86)\TestApp\TestApp.ico"; //uncomment to set the icon of the shortcut
|
||||||
|
shortcut.TargetPath = pathToExe;
|
||||||
|
shortcut.Save();
|
||||||
|
}
|
||||||
private void disableAutostart()
|
private void disableAutostart()
|
||||||
{
|
{
|
||||||
RegistryKey key = Registry.CurrentUser.CreateSubKey(subkey);
|
RegistryKey key = Registry.CurrentUser.CreateSubKey(subkey);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
@ -25,6 +24,9 @@
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
|
@ -35,16 +37,18 @@
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System"/>
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Core"/>
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Data"/>
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml"/>
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="System.Xaml">
|
<Reference Include="System.Xaml">
|
||||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="WindowsBase"/>
|
<Reference Include="WindowsBase" />
|
||||||
<Reference Include="PresentationCore"/>
|
<Reference Include="PresentationCore" />
|
||||||
<Reference Include="PresentationFramework"/>
|
<Reference Include="PresentationFramework" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ApplicationDefinition Include="App.xaml">
|
<ApplicationDefinition Include="App.xaml">
|
||||||
|
@ -79,7 +83,21 @@
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config"/>
|
<None Include="App.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
|
<ItemGroup>
|
||||||
|
<COMReference Include="IWshRuntimeLibrary">
|
||||||
|
<Guid>{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}</Guid>
|
||||||
|
<VersionMajor>1</VersionMajor>
|
||||||
|
<VersionMinor>0</VersionMinor>
|
||||||
|
<Lcid>0</Lcid>
|
||||||
|
<WrapperTool>tlbimp</WrapperTool>
|
||||||
|
<Isolated>False</Isolated>
|
||||||
|
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||||
|
</COMReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="app.manifest" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
12
WeeXnes_UAC/app.manifest
Normal file
12
WeeXnes_UAC/app.manifest
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
|
||||||
|
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||||
|
<assemblyIdentity version="1.0.0.0" name="YourAppName.app"/>
|
||||||
|
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||||
|
<security>
|
||||||
|
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
|
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||||
|
</requestedPrivileges>
|
||||||
|
</security>
|
||||||
|
</trustInfo>
|
||||||
|
</assembly>
|
Loading…
Add table
Reference in a new issue