Customizing Notification Features in Meshcentral #6005
Unanswered
amoljagdalepucsd
asked this question in
Q&A
Replies: 1 comment 4 replies
-
you cant just change the JS files that are located inside the MeshAgent sourcecode. but you can PATCH the meshagent to see if things work before actually fully compiling the exe |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Greetings, community! In Meshcentral, we have a notify-user feature used to display notifications on remote devices, notifying users after a session starts. However, I aim to customize this feature by changing the default system icon to the Meshcentral logo or a custom icon, along with altering the window title (Windows Powershell to Meshcentral ) . After conducting some research, I've discovered that this customization requires modifications to the Meshagent source code.
Below is a snippet of code from the "toaster.JS" file, where notifications are formed on the remote system by executing a PowerShell script within a Node.js child process: we are loading system.windows.forms assembly .NET classes. I tried changing $objBalloon.Icon with different approaches and other scripts as well but did not work.
Can someone please help me in this.
// Spawn a PowerShell process to set up the notification toast
retVal.child = require('child_process').execFile(process.env['windir'] + '\System32\WindowsPowerShell\v1.0\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', '-'], retVal.options);
retVal.child.descriptorMetadata = 'toaster';
retVal.child.toast = retVal;
retVal.child.stdout.stdin = retVal.child.stdin;
retVal.child.stderr.stdin = retVal.child.stdin;
// Handle toast dismissal event
retVal.child.stdout.on('data', function (c) {
if (c.toString().includes('')) {
this.stdin.write('exit\n');
}
});
// Set up PowerShell script for the notification
retVal.child.stderr.once('data', function (c) {
this.stdin.write('$objBalloon.dispose();exit\n');
});
retVal.child.stdin.write('[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")\r\n');
retVal.child.stdin.write('$objBalloon = New-Object System.Windows.Forms.NotifyIcon\r\n');
retVal.child.stdin.write('$objBalloon.Icon = [System.Drawing.SystemIcons]::Information\r\n');
retVal.child.stdin.write('$objBalloon.Visible = $True\r\n');
retVal.child.stdin.write('Register-ObjectEvent -InputObject $objBalloon -EventName BalloonTipClosed -Action { $objBalloon.dispose();Write-Host "<
DISMISSED
>" }\r\n');retVal.child.stdin.write('$objBalloon.ShowBalloonTip(10000, $env:_title, $env:_caption, 1)\r\n');
// Set a timeout to clean up after 10 seconds if the user doesn't interact with the toast
retVal.child.timeout = setTimeout(function (c) {
c.timeout = null;
c.stdin.write('$objBalloon.dispose();exit\n');
}, 10000, retVal.child);
// Handler for PowerShell process exit
retVal.child.on('exit', function () {
if (this.timeout != null) {
clearTimeout(this.timeout);
}
this.toast._res('DISMISSED');
});
return (retVal);
This is the screenshot :
![notify](https://private-user-images.githubusercontent.com/48832403/320895775-4f411c49-7dec-4352-a6a7-8ecca1f39fb7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk2NzIyMDYsIm5iZiI6MTcxOTY3MTkwNiwicGF0aCI6Ii80ODgzMjQwMy8zMjA4OTU3NzUtNGY0MTFjNDktN2RlYy00MzUyLWE2YTctOGVjY2ExZjM5ZmI3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI5VDE0MzgyNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFlYTMyZWYzZGJkMWY4MWFlMzIxYjQyNTM2MjQ3MTI0N2I1NWMyYjI2OGM0MjIwZWZhYjRiODI1ZTM3ODVlMTkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.1ugWwkHajfcvwXBGb6GblOoYeqsKjcaLeVcBq_ZO7AQ)
Beta Was this translation helpful? Give feedback.
All reactions