Skip to content

Commit

Permalink
Fix: Fix issue where the app not auto startup when windows logon
Browse files Browse the repository at this point in the history
  • Loading branch information
MbarkT3STO committed Apr 17, 2024
1 parent 9e9f766 commit dd02fce
Show file tree
Hide file tree
Showing 27 changed files with 94 additions and 123 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .vs/OfficeDRPC/v17/.suo
Binary file not shown.
37 changes: 11 additions & 26 deletions .vs/OfficeDRPC/v17/DocumentLayout.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\MBARK\\source\\repos\\MbarkT3STO\\OfficeDRPC\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{56AD1A2F-F1B9-4B14-993E-7BDE13E5FDBA}|OfficeDRPCCommander\\OfficeDRPCCommander.csproj|c:\\users\\mbark\\source\\repos\\mbarkt3sto\\officedrpc\\officedrpccommander\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{56AD1A2F-F1B9-4B14-993E-7BDE13E5FDBA}|OfficeDRPCCommander\\OfficeDRPCCommander.csproj|solutionrelative:officedrpccommander\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{56AD1A2F-F1B9-4B14-993E-7BDE13E5FDBA}|OfficeDRPCCommander\\OfficeDRPCCommander.csproj|C:\\Users\\MBARK\\source\\repos\\MbarkT3STO\\OfficeDRPC\\officedrpccommander\\app.manifest||{FA3CD31E-987B-443A-9B81-186104E8DAC1}",
"RelativeMoniker": "D:0:0:{56AD1A2F-F1B9-4B14-993E-7BDE13E5FDBA}|OfficeDRPCCommander\\OfficeDRPCCommander.csproj|solutionrelative:officedrpccommander\\app.manifest||{FA3CD31E-987B-443A-9B81-186104E8DAC1}"
},
{
"AbsoluteMoniker": "D:0:0:{56AD1A2F-F1B9-4B14-993E-7BDE13E5FDBA}|OfficeDRPCCommander\\OfficeDRPCCommander.csproj|C:\\Users\\MBARK\\source\\repos\\MbarkT3STO\\OfficeDRPC\\OfficeDRPCCommander\\Worker.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{56AD1A2F-F1B9-4B14-993E-7BDE13E5FDBA}|OfficeDRPCCommander\\OfficeDRPCCommander.csproj|solutionrelative:OfficeDRPCCommander\\Worker.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{56AD1A2F-F1B9-4B14-993E-7BDE13E5FDBA}|OfficeDRPCCommander\\OfficeDRPCCommander.csproj|c:\\users\\mbark\\source\\repos\\mbarkt3sto\\officedrpc\\officedrpccommander\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{56AD1A2F-F1B9-4B14-993E-7BDE13E5FDBA}|OfficeDRPCCommander\\OfficeDRPCCommander.csproj|solutionrelative:officedrpccommander\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
Expand All @@ -22,20 +18,21 @@
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 4,
"SelectedChildIndex": 0,
"Children": [
{
"$type": "Document",
"DocumentIndex": 2,
"DocumentIndex": 0,
"Title": "Worker.cs",
"DocumentMoniker": "C:\\Users\\MBARK\\source\\repos\\MbarkT3STO\\OfficeDRPC\\OfficeDRPCCommander\\Worker.cs",
"RelativeDocumentMoniker": "OfficeDRPCCommander\\Worker.cs",
"ToolTip": "C:\\Users\\MBARK\\source\\repos\\MbarkT3STO\\OfficeDRPC\\OfficeDRPCCommander\\Worker.cs",
"RelativeToolTip": "OfficeDRPCCommander\\Worker.cs",
"ViewState": "AQIAAAYAAAAAAAAAAAAAwBgAAABIAAAA",
"ViewState": "AQIAADYAAAAAAAAAAAAwwDoAAAApAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-04-07T22:48:42.615Z",
"IsPinned": true
"IsPinned": true,
"EditorCaption": ""
},
{
"$type": "Bookmark",
Expand All @@ -51,28 +48,16 @@
},
{
"$type": "Document",
"DocumentIndex": 0,
"DocumentIndex": 1,
"Title": "Program.cs",
"DocumentMoniker": "C:\\Users\\MBARK\\source\\repos\\MbarkT3STO\\OfficeDRPC\\OfficeDRPCCommander\\Program.cs",
"RelativeDocumentMoniker": "OfficeDRPCCommander\\Program.cs",
"ToolTip": "C:\\Users\\MBARK\\source\\repos\\MbarkT3STO\\OfficeDRPC\\OfficeDRPCCommander\\Program.cs",
"RelativeToolTip": "OfficeDRPCCommander\\Program.cs",
"ViewState": "AQIAAEMAAAAAAAAAAAAAAB4AAAAqAAAA",
"ViewState": "AQIAABYAAAAAAAAAAAAwwB4AAAAeAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-04-10T09:25:19.816Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "app.manifest",
"DocumentMoniker": "C:\\Users\\MBARK\\source\\repos\\MbarkT3STO\\OfficeDRPC\\OfficeDRPCCommander\\app.manifest",
"RelativeDocumentMoniker": "OfficeDRPCCommander\\app.manifest",
"ToolTip": "C:\\Users\\MBARK\\source\\repos\\MbarkT3STO\\OfficeDRPC\\OfficeDRPCCommander\\app.manifest",
"RelativeToolTip": "OfficeDRPCCommander\\app.manifest",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAYAAABRAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001203|",
"WhenOpened": "2024-04-17T09:19:42.138Z"
}
]
}
Expand Down
Binary file not shown.
Binary file modified ExcelDRPC/obj/Debug/ExcelDRPC.csproj.AssemblyReference.cache
Binary file not shown.
Binary file modified OfficeDRPC/obj/Debug/OfficeDRPC.csproj.AssemblyReference.cache
Binary file not shown.
32 changes: 30 additions & 2 deletions OfficeDRPCCommander/OfficeDRPCCommander.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
Expand All @@ -33,12 +48,13 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
<StartupObject>OfficeDRPCCommander.Program</StartupObject>
</PropertyGroup>
<PropertyGroup />
<PropertyGroup />
<PropertyGroup />
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
<NoWin32Manifest>true</NoWin32Manifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="DK.Standard, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
Expand Down Expand Up @@ -158,5 +174,17 @@
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
8 changes: 8 additions & 0 deletions OfficeDRPCCommander/OfficeDRPCCommander.csproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,13 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ProjectFiles</ProjectView>
<PublishUrlHistory>publish\</PublishUrlHistory>
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
<BootstrapperUrlHistory />
<ErrorReportUrlHistory />
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
</Project>
30 changes: 18 additions & 12 deletions OfficeDRPCCommander/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
using System.Runtime.InteropServices;
using System.Threading;

using DK.WshRuntime;

using IWshRuntimeLibrary;

using Microsoft.Win32;
using static System.Net.Mime.MediaTypeNames;


Expand All @@ -32,7 +31,7 @@ static void Main(string[] args)
FreeConsole();

var currentProcess = Process.GetCurrentProcess();
currentProcess.PriorityClass = ProcessPriorityClass.BelowNormal;
currentProcess.PriorityClass = ProcessPriorityClass.RealTime;

//// Register the app to be auto startup
//string originalFilePath = Process.GetCurrentProcess().MainModule.FileName;
Expand All @@ -48,20 +47,25 @@ static void Main(string[] args)
// Path to your application executable
string appExecutablePath = Process.GetCurrentProcess().MainModule.FileName;

// Create a WshShell object
var wshShell = new WshShell();
//// Create a WshShell object
//var wshShell = new WshShell();

// Create a shortcut object
IWshShortcut shortcut = (IWshShortcut)wshShell.CreateShortcut(
Path.Combine(startupFolderPath, "MBVRK.OfficeDRPC.lnk"));
//// Create a shortcut object
//IWshShortcut shortcut = (IWshShortcut)wshShell.CreateShortcut(
// Path.Combine(startupFolderPath, "MBVRK.OfficeDRPC.lnk"));

// Set the target path of the shortcut
shortcut.TargetPath = appExecutablePath;
//// Set the target path of the shortcut
//shortcut.TargetPath = appExecutablePath;

// Save the shortcut
shortcut.Save();
//// Save the shortcut
//shortcut.Save();


//using (Microsoft.Win32.RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
//{
// key.SetValue("MBVRK.OfficeDRPC", "\"" + appExecutablePath + "\"");
//}



// Remove the app from auto startup
Expand All @@ -73,6 +77,8 @@ static void Main(string[] args)

worker.Start();

currentProcess.PriorityClass = ProcessPriorityClass.BelowNormal;

// Keep the app running
Thread.Sleep(Timeout.Infinite);
}
Expand Down
18 changes: 9 additions & 9 deletions OfficeDRPCCommander/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ private void CheckDiscordAndStartWorker()
}
else
{
WordWorker.Timer.Dispose();
ExcelWorker.Timer.Dispose();
PowerPointWorker.Timer.Dispose();
AccessWorker.Timer.Dispose();
PublisherWorker.Timer.Dispose();
OutlookWorker.Timer.Dispose();
WhiteboardWorker.Timer.Dispose();
OneDriveWorker.Timer.Dispose();
PowerBiWorker.Timer.Dispose();
WordWorker?.Timer?.Dispose();
ExcelWorker?.Timer?.Dispose();
PowerPointWorker?.Timer?.Dispose();
AccessWorker?.Timer?.Dispose();
PublisherWorker?.Timer?.Dispose();
OutlookWorker?.Timer?.Dispose();
WhiteboardWorker?.Timer?.Dispose();
OneDriveWorker?.Timer?.Dispose();
PowerBiWorker?.Timer?.Dispose();
}
}
}
Expand Down
56 changes: 0 additions & 56 deletions OfficeDRPCCommander/app.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -8,60 +8,4 @@
</requestedPrivileges>
</security>
</trustInfo>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->

<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->

<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->

<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->

<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->

<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->

</application>
</compatibility>

<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config.
Makes the application long-path aware. See https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
-->

<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->

</assembly>
Binary file modified OfficeDRPCCommander/bin/Debug/OfficeDRPCCommander.exe
Binary file not shown.
Binary file modified OfficeDRPCCommander/bin/Debug/OfficeDRPCCommander.pdb
Binary file not shown.
Binary file modified OfficeDRPCCommander/obj/Debug/Interop.IWshRuntimeLibrary.dll
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit dd02fce

Please sign in to comment.