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
|
@ -62,6 +62,14 @@
|
|||
Click="CheckForUpdateBtn_OnClick"
|
||||
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>
|
||||
|
||||
|
|
|
@ -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.IO;
|
||||
using System.Windows;
|
||||
using IWshRuntimeLibrary;
|
||||
using Microsoft.Win32;
|
||||
using Application = System.Windows.Forms.Application;
|
||||
|
||||
namespace WeeXnes_UAC
|
||||
{
|
||||
|
@ -25,6 +28,11 @@ namespace WeeXnes_UAC
|
|||
{
|
||||
disableAutostart();
|
||||
}
|
||||
|
||||
if (e.Args[i] == "-CreateStartMenuShortcut")
|
||||
{
|
||||
AddShortcut();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -32,7 +40,28 @@ namespace WeeXnes_UAC
|
|||
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()
|
||||
{
|
||||
RegistryKey key = Registry.CurrentUser.CreateSubKey(subkey);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
|
||||
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
|
@ -25,6 +24,9 @@
|
|||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@ -35,16 +37,18 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System"/>
|
||||
<Reference Include="System.Core"/>
|
||||
<Reference Include="System.Data"/>
|
||||
<Reference Include="System.Xml"/>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase"/>
|
||||
<Reference Include="PresentationCore"/>
|
||||
<Reference Include="PresentationFramework"/>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
|
@ -79,7 +83,21 @@
|
|||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config"/>
|
||||
<None Include="App.config" />
|
||||
</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>
|
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