From cdbc52daf36146507533429ccc2bf8892b7adf6d Mon Sep 17 00:00:00 2001 From: s_falahati Date: Sat, 18 Apr 2020 23:11:35 +0430 Subject: [PATCH] Ported to NetStandard2 --- startup-logo.png => StartupHelper/Icon.png | Bin StartupHelper/Properties/AssemblyInfo.cs | 36 --------- StartupHelper/StartupHelper.csproj | 87 ++++++++++----------- StartupHelper/StartupHelper.nuspec | 17 ---- StartupHelper/StartupManager.cs | 13 ++- StartupHelper/packages.config | 4 - build.ps1 | 2 - 7 files changed, 46 insertions(+), 113 deletions(-) rename startup-logo.png => StartupHelper/Icon.png (100%) delete mode 100644 StartupHelper/Properties/AssemblyInfo.cs delete mode 100644 StartupHelper/StartupHelper.nuspec delete mode 100644 StartupHelper/packages.config delete mode 100644 build.ps1 diff --git a/startup-logo.png b/StartupHelper/Icon.png similarity index 100% rename from startup-logo.png rename to StartupHelper/Icon.png diff --git a/StartupHelper/Properties/AssemblyInfo.cs b/StartupHelper/Properties/AssemblyInfo.cs deleted file mode 100644 index 5de95b2..0000000 --- a/StartupHelper/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("A .Net library to add or remove your program to the startup list as well as detecting the startup session")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Startup Helper")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5d71ad0c-a697-4cb1-b7a4-8395ba7d6d4c")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.2.0")] -[assembly: AssemblyFileVersion("1.0.2.0")] diff --git a/StartupHelper/StartupHelper.csproj b/StartupHelper/StartupHelper.csproj index fc53855..3e41ec0 100644 --- a/StartupHelper/StartupHelper.csproj +++ b/StartupHelper/StartupHelper.csproj @@ -1,57 +1,50 @@  - - + - Debug - AnyCPU - {5D71AD0C-A697-4CB1-B7A4-8395BA7D6D4C} - Library - Properties - StartupHelper - StartupHelper - 512 - + netstandard2.0;net4 + 1.0.3.4 + falahati.net + A .Net library to add or remove your program to the startup list as well as detecting the startup session. Supporting Windows XP+ with and without administrator rights. + Soroush Falahati + Copyright © Soroush Falahati 2016-2020 (falahati.net) + AnyCPU + StartupHelper + https://github.com/falahati/StartupHelper + https://github.com/falahati/StartupHelper/blob/master/LICENSE + https://github.com/falahati/StartupHelper/blob/master/StartupHelper/Icon.png?raw=true + true + true + AnyCPU + Startup Helper (Win XP+) + StartupHelper - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - v2.0 - - + + dev + 4 + ..\Debug - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - v2.0 - bin\Release\StartupHelper.xml + + True + dev + true + ..\Release + ..\Release\StartupHelper.xml - - ..\packages\TaskScheduler.2.5.19\lib\net20\Microsoft.Win32.TaskScheduler.dll - True - - - + + all + runtime; build; native; contentfiles; analyzers + + - - - - + + true + \ + + + true + \ + - - - - - - \ No newline at end of file diff --git a/StartupHelper/StartupHelper.nuspec b/StartupHelper/StartupHelper.nuspec deleted file mode 100644 index e0e8c3d..0000000 --- a/StartupHelper/StartupHelper.nuspec +++ /dev/null @@ -1,17 +0,0 @@ - - - - StartupHelper - 0.0 - Startup Helper (Win XP+) - Soroush Falahati - https://github.com/falahati/StartupHelper/blob/master/LICENSE - https://github.com/falahati/StartupHelper - false - A .Net library to add or remove your program to the startup list as well as detecting the startup session. Supporting Windows XP+ with and without administrator rights. - en-US - - - - - \ No newline at end of file diff --git a/StartupHelper/StartupManager.cs b/StartupHelper/StartupManager.cs index 0bfef20..fd957c3 100644 --- a/StartupHelper/StartupManager.cs +++ b/StartupHelper/StartupManager.cs @@ -49,7 +49,7 @@ public StartupManager(string name, RegistrationScope scope) /// rights /// public StartupManager(string name, RegistrationScope scope, bool needsAdminPrivileges) - : this(Assembly.GetEntryAssembly().Location, name, scope, needsAdminPrivileges) + : this(Assembly.GetEntryAssembly()?.Location, name, scope, needsAdminPrivileges) { FixWorkingDirectory(); } @@ -184,7 +184,7 @@ public StartupManager(string applicationImage, string name, RegistrationScope sc public StartupManager(string applicationImage, string name, RegistrationScope scope, bool needsAdminPrivileges, StartupProviders provider, string startupSpecialArgument) { - if (!File.Exists(applicationImage)) + if (string.IsNullOrEmpty(applicationImage) || !File.Exists(applicationImage)) { throw new ArgumentException("File doesn't exist.", nameof(applicationImage)); } @@ -233,8 +233,7 @@ public static bool IsElevated get { var currentUser = WindowsIdentity.GetCurrent(); - return currentUser != null && - new WindowsPrincipal(currentUser).IsInRole(WindowsBuiltInRole.Administrator); + return new WindowsPrincipal(currentUser).IsInRole(WindowsBuiltInRole.Administrator); } } @@ -442,7 +441,7 @@ public bool Register(string arguments = null) : TaskRunLevel.LUA; if (RegistrationScope == RegistrationScope.Local) { - taskTrigger.UserId = WindowsIdentity.GetCurrent()?.Name; + taskTrigger.UserId = WindowsIdentity.GetCurrent().Name; } } else @@ -460,7 +459,7 @@ public bool Register(string arguments = null) else { newTask.Principal.LogonType = TaskLogonType.InteractiveToken; - newTask.Principal.UserId = WindowsIdentity.GetCurrent()?.Name; + newTask.Principal.UserId = WindowsIdentity.GetCurrent().Name; } newTask.Actions.Add(taskAction); newTask.Triggers.Add(taskTrigger); @@ -507,7 +506,7 @@ private static bool IsCurrentUser(string username) try { return ((SecurityIdentifier) (new NTAccount(username).Translate(typeof (SecurityIdentifier)))) == - WindowsIdentity.GetCurrent()?.User; + WindowsIdentity.GetCurrent().User; } catch { diff --git a/StartupHelper/packages.config b/StartupHelper/packages.config deleted file mode 100644 index 8791b5c..0000000 --- a/StartupHelper/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/build.ps1 b/build.ps1 deleted file mode 100644 index ac141b7..0000000 --- a/build.ps1 +++ /dev/null @@ -1,2 +0,0 @@ -$msbuild = join-path -path (Get-ItemProperty "HKLM:\software\Microsoft\MSBuild\ToolsVersions\14.0")."MSBuildToolsPath" -childpath "msbuild.exe" -&$msbuild StartupHelper\StartupHelper.csproj /t:Build /t:Package /t:Publish /p:Configuration="Release" \ No newline at end of file