field-effect-llc / rdp-battmon Goto Github PK
View Code? Open in Web Editor NEWA Microsoft RDP Client (MSTSC) Plugin to Report Device Battery Life
A Microsoft RDP Client (MSTSC) Plugin to Report Device Battery Life
When computer is closed & hibernates, exception occurs
2018-03-10 14:51:34,420 [8] FATAL FieldEffect.Program [(null)] - FieldEffect.VCL.Exceptions.VirtualChannelException: TsClientAddIn (BATTMON): Couldn't write to communcation channel for battery monitor.
at FieldEffect.VCL.Client.RdpClientVirtualChannel.VirtualChannelWrite(Byte[] data) in C:\Users\russosv\Documents\Visual Studio 2017\Projects\RDP Laptop Battery Monitor\RDP Virtual Channel Library\Client\RdpClientVirtualChannel.cs:line 60
at FieldEffect.Models.BatteryDataReporter._clientAddIn_DataChannelEvent(Object sender, DataChannelEventArgs e) in C:\Users\russosv\Documents\Visual Studio 2017\Projects\RDP Laptop Battery Monitor\Client MSTSC Add-in\Models\BatteryDataReporter.cs:line 87
at FieldEffect.VCL.Client.RdpClientVirtualChannel.OnDataChannelEvent(DataChannelEventArgs e) in C:\Users\russosv\Documents\Visual Studio 2017\Projects\RDP Laptop Battery Monitor\RDP Virtual Channel Library\Client\RdpClientVirtualChannel.cs:line 100
at FieldEffect.VCL.Client.RdpClientVirtualChannel.VirtualChannelOpenEvent(Int32 openHandle, ChannelEvents Event, Byte[] data, Int32 dataLength, UInt32 totalLength, ChannelFlags dataFlags) in C:\Users\russosv\Documents\Visual Studio 2017\Projects\RDP Laptop Battery Monitor\RDP Virtual Channel Library\Client\RdpClientVirtualChannel.cs:line 117
Reported in #8
This is reproduceable. It does not crash the client or server or application. Clicking continue leaves everything running, with proper data.
Nothing appears on the server log, but I get a JIT error popping up when I connect.
Hi,
I don't wanna sound ungrateful for your project, but I really don't know how to do this, and want to use a Surface RT as a RDP client. It's in test mode and I can sign apps with my own key.
Could you provide me with a build for ARM architecture used on Surface RT? (Windows RT 8.1).
Thank you very much.
App had been running for several days without issue. Logged in today and the app was displaying the X icon, indicating there was no battery data.
Stack trace:
at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
at System.Drawing.Icon.BmpFrame()
at System.Windows.Forms.ThreadExceptionDialog..ctor(Exception t)
at System.Windows.Forms.Application.ThreadContext.OnThreadException(Exception t)
at System.Windows.Forms.Control.WndProcException(Exception e)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Even though we don't have the file name/line number, this has to be occurring in the BatteryIcon.cs
file, because that's the only place we're dealing with bitmaps.
Gray color matches the taskbar too closely. Change the color scheme and/or allow user to use custom icons.
Hi @transistor1
Cool application! I am having an issue installing it properly though. The registry path "HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client" wasn't on my client machine, so I went ahead and created it and added the path to the client dll at "HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default\AddIns\BattMon".
When I go to run the server application on the RDP server it cannot find the client battery. I am assuming it is because "HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client" isn't properly configured on my machine. How would I go about properly installing that so I am able to use RDP add-ins?
I think it would be good if both client & server log configuration worked exactly the same way. I think it might be better to use the log4net.config
file — rather than an exe.config file — on both sides, because DLLs aren't really supposed to support .config files. More ideally, logging should be configured by an MSTSC.exe.config, but that’s not likely to be feasible, since (a) many users won’t have access to create a config file alongside a system executable, and (b) I’m not sure if you can write a .NET config file for an unmanaged executable.
Also, maybe change log4net.config
to BattMon_Log.config
for more clarity, and to avoid potential naming conflicts, if there are other files in the same folder?
For ease of translation
To avoid confusion with installation we need to write an installer for the client application.
Installer should be able to be used by non-admins (that is, it should not raise the UAC prompt). This is doable in WiX installer, though other suggestions welcome.
When charging on AC, add a special icon
Greetings! I'm the superuser question creator.
How should I go about compiling this? Do I need VS?
I use a Lenovo x240 and that entire series of laptop has two batteries.
When the computer is plugged in, it has a BatteryStatus of 2, and thus appears as "Unknown" (at least on my machine).
However, according to:
https://msdn.microsoft.com/en-us/library/aa394074%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
Unknown (2)
The system has access to AC so no battery is being discharged. However, the battery is not necessarily charging.
When battery level is unknown, add an icon to designate that
Crash Reported in #8
- <System>
<Provider Name="Windows Error Reporting" />
<EventID Qualifiers="0">1001</EventID>
<Level>4</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2018-03-06T03:38:22.594850200Z" />
<EventRecordID>30242</EventRecordID>
<Channel>Application</Channel>
<Computer>Lappy2010</Computer>
<Security />
</System>
- <EventData>
<Data>1833787917323518067</Data>
<Data>5</Data>
<Data>CLR20r3</Data>
<Data>Not available</Data>
<Data>0</Data>
<Data>mstsc.exe</Data>
<Data>10.0.16299.15</Data>
<Data>3a40081f</Data>
<Data>RDS_Client_Addin_BattMon</Data>
<Data>1.0.1.0</Data>
<Data>5a9e0ad3</Data>
<Data>2b</Data>
<Data>68</Data>
<Data>System.NullReferenceException</Data>
<Data />
<Data>\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER2B8A.tmp.mdmp \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER34A4.tmp.WERInternalMetadata.xml \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER34B1.tmp.csv \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER34F1.tmp.txt \\?\C:\Users\Peter Berbec\AppData\Local\Temp\WER4280.tmp.appcompat.txt \\?\C:\Users\Peter Berbec\AppData\Local\Temp\WER42A0.tmp.WERDataCollectionStatus.txt</Data>
<Data>C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_mstsc.exe_3edcc19b72aba3b85e9781e9c4bda1e80e62e59_2d2465bf_15dc42da</Data>
<Data />
<Data>0</Data>
<Data>ffe79c66-7891-4e97-a06e-aa69ea2fc2f9</Data>
<Data>2147487752</Data>
<Data>9792ade44c9760f5f972ec651d78c073</Data>
</EventData>
</Event>
- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
<Provider Name="Application Error" />
<EventID Qualifiers="0">1000</EventID>
<Level>2</Level>
<Task>100</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2018-03-06T03:38:16.126011400Z" />
<EventRecordID>30241</EventRecordID>
<Channel>Application</Channel>
<Computer>Lappy2010</Computer>
<Security />
</System>
- <EventData>
<Data>mstsc.exe</Data>
<Data>10.0.16299.15</Data>
<Data>3a40081f</Data>
<Data>unknown</Data>
<Data>0.0.0.0</Data>
<Data>00000000</Data>
<Data>c0000005</Data>
<Data>00007ffb0c14bff9</Data>
<Data>e0c</Data>
<Data>01d3b4fc844c4599</Data>
<Data>C:\Windows\system32\mstsc.exe</Data>
<Data>unknown</Data>
<Data>ffe79c66-7891-4e97-a06e-aa69ea2fc2f9</Data>
<Data />
<Data />
</EventData>
</Event>
- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
<Provider Name=".NET Runtime" />
<EventID Qualifiers="0">1026</EventID>
<Level>2</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2018-03-06T03:38:14.704141900Z" />
<EventRecordID>30240</EventRecordID>
<Channel>Application</Channel>
<Computer>Lappy2010</Computer>
<Security />
</System>
- <EventData>
<Data>Application: mstsc.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.NullReferenceException at FieldEffect.Classes.Win32BatteryManagementObjectSearcher.GetAllBatteries() at FieldEffect.Models.BatteryDataReporter._clientAddIn_DataChannelEvent(System.Object, FieldEffect.VCL.Client.DataChannelEventArgs) at FieldEffect.VCL.Client.RdpClientVirtualChannel.OnDataChannelEvent(FieldEffect.VCL.Client.DataChannelEventArgs) at FieldEffect.VCL.Client.RdpClientVirtualChannel.VirtualChannelOpenEvent(Int32, FieldEffect.VCL.Client.WtsApi32.ChannelEvents, Byte[], Int32, UInt32, FieldEffect.VCL.Client.WtsApi32.ChannelFlags)</Data>
</EventData>
</Event>
Make a NuGet package to allow anyone to easily leverage the VCL module to write RDP Client addins.
There's a tab in Advanced settings called "Programs" that allows you to start a program on the remote machine when your connection starts. Therefore it may be possible to do this programmatically in the client side add-in.
Also, RDP has the ability to upload files. If I do ctrl-C on a file on the client side, and ctrl-V in the server window, it will copy the file from client to server.
If it is possible to do both of these programmatically, it might be possible to copy the server side EXE to a temp folder upon connection, and start it automatically. Then the battery reporting would happen automatically as long as the client add-in is installed, so it'd show up on whatever host you connect to. That'd be cool.
Client add-in should be logging to the Event Viewer's application log, but it's not. Log4Net misconfiguration.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.