I'm developing a program in mono/C# which will run on a Linux embedded platform with a touch-screen.
I've installed OpenBox in top of Raspbian, because this will run in "kiosk mode" and I'm trying to keep it as simple as possible.
I was planning to have two options in the program:
option to shutdown the computer
option to close the windows manager (openbox) and return to the terminal
For the first option I've tried using:
shutdown
poweroff
systcl poweroff
commands but all require special privileges, so I'm not sure on what would be the best approach. Should I create a bash script with root privileges and run this script from the program?
For the second option, I don't even know how to start. I've configured openbox to be able to close it from the keyboard through Ctrl + Alt + Backspace, but I know how to close it from the program.
I've tried using SendKeys with that key combination but does not work.
I've also tried the solution here using DBUS for C# but I've issues compiling it.
Could you please give any advice?
You can set your sudo program up to let a user run a program without any password.
Add to your visudo file:
<username-or-ALL> ALL=(ALL) NOPASSWD:/sbin/poweroff
See this maybe
If I were you, I would reboot after setting up and before testing.
Related
I developed an application in C#.
When I try to run it, the following Windows Smart Screen pop-up show up:
see image
Clicking on "Run Anyway", the program start without problem.
As I need to install this exe on more computer, will be better that the program run without show this pop-up.
Reading on google I figure out that I need a certificate for running the program.
Anyone could help me about how generate a certificate? I don't want to pay for one.
Thanks in advance.
This is my first question on here, so bear with me.
I'm working on a winforms GUI in C# that communicates with a RasPi running test hardware. Most of that works fine, but something new I was asked to add doesn't yet.
So, one of the forms has a button that opens another form which lets us toggle specific bits on various ICs on the hardware. Someone wrote a utility on the RasPi which displays the state of those bits in a SSH window (usually PuTTy, but also works through cmd->ssh in Win10).
(For anyone who cares, we're trying to move away from PuTTy (or any other 3rd party tool) for this so we don't have to figure out packaging it into our installer. Some of our clients have no networks beyond their PC and the test hardware.)
SSH Login
Utility, opened from File Explorer
What I was asked to do is open this utility alongside the second form. Sounds simple enough, but I can't figure out how to get it working.
I have a .cmd in a folder on my desktop that launches the utility just fine when I click to run. All it has in it is "ssh -t semitek#{ip} /usr/semitekutil/outs".
In my GUI (Running through VS 2019, with the project on a company server), I tried pointing it to that cmd file like this:
outs.StartInfo.FileName = #"C:\Users\jfink\Desktop\4xDebugLEDs\4xPiOuts_NoPutty.cmd";
outs.StartInfo.WorkingDirectory = #"C:\Users\Default\Desktop\4xDebugLEDs\";
outs.Start();
And this:
outs.StartInfo.FileName = "cmd.exe";
outs.StartInfo.WorkingDirectory = #"C:\Users\Default\Desktop\";
outs.StartInfo.UseShellExecute = true;
outs.StartInfo.Arguments = "ssh -t semitek#" + df.IPaddr + " /usr/semitekutil/outs";
outs.Start();
Both of which give me this:
Starting through GUI
Utility started through GUI
I've also tried:
Process.Start("cmd.exe", "ssh -t semitek#192.168.50.102 /usr/semitekutil/outs");
but that doesn't execute the argument.
Process.Start() with args
Can anyone help point me in the right direction? I don't understand why clicking the cmd in File Explorer works just fine, but calling it through the GUI doesn't, nor why the utility displays differently for each access method...
Thanks in advance!
I am building a vb.net application which monitors external process and kills the process based on certain conditions. The application works great with monitoring .exe process but i m unable to use it with control pannel items.
Suppose a user launches programs and features , I want my vb.net app to detect it and kill it. Under task manager the process is shown as explorer.exe.
I can successfully launch programs and features using Process.Start(System.Environment.SystemDirectory + "\appwiz.cpl")
but i cannot kill it this way, can anyone tell me how i could kill this process??
Thanks!
You can use the following:
Process.Start("taskkill.exe /im explorer.exe")
Just replace explorer.exe with the process you wanna stop/kill...
Also works with the PID (Process ID):
Process.Start("taskkill.exe /pid /*yourPID*/")
Do not kill applications until there is other way to exit them.
It is like finishing your day by instantly turning off your computer.
First, at least ask applications to close themselves:
Please see Microsoft article How to use Visual Basic .NET or Visual Basic 2005 to close another application how to implement closing request.
Also please have a look at this Q&A how to prevent application to be uninstalled by a user (w/o admin rights)?.
I've written a shell extension using EZShellExtensions.net. It works great in my development environment when I'm logged in as me, as well as any other system when logged in as me. For all other users, the copy-hook I've created never appears. I've used NirSoft's RegDLLView to verify that the DLL is registered, but no luck.
What can I check to see why this is occurring?
FYI
I'm happy to send a copy of my code to whomever wants to help out with this. EZShellExtensions.NET has an evaluation period of 30 days.
UPDATE
ProcMon Output when using the vendor's registration tool now available as a CSV/PML file if anyone's interested.
RESOLVE
I wound up adding console output to the dll for debugging. turns out that a timer wasn't kicking off when running as any user but me (no idea why). This has since been fixed.
That indicates that the shell extension got registered in the HKCU\Software hive instead of HKLM\Software. Only the latter hive makes extensions available to all users. This commonly happens because UAC prevents writing to HKLM\Software unless the program that does the writing is elevated.
If this library comes with a dedicated registration program, they usually do, then be sure to run it from an elevated command prompt. Start + All Programs, Accessories folder, right-click the Command Prompt link and click "Run as administrator". Rerun the registration tool.
If you still have trouble then SysInternal's ProcMon tool can show you exactly where stuff gets written. And don't hesitate to use the vendor's support channels.
I have just begun to explore the mono winforms environment and I cannot work out how to start a program from within monodevelop without a console session being started.
My simple program runs okay but when it exits a terminal session is always created & waiting for me to 'press any key'. I guess I could arrange things so that the terminal window closes automatically, but I would rather the app just ran 'natively', is this possible or does the way mono & .net function work preclude it?
As shown in the examples at Zetcode, in 'Main' the rest of the code is started with 'application.run(new aFunction());', I thought this might be the cause of the terminal session occurring but replacing it with:
myNewClass n = new myNewClass();
n.aFunction();
causes the program to not run at all (or maybe just exit without doing anything).
I am an experienced programmer but not familiar at all with C# or the mono/.net environment so 'stating the obvious' may be all that is required in an answer.
MonoDevelop will usually let you start a program with or without it running in an external console.
In MonoDevelop 2.8 on Linux you can control this by context clicking on a project in the solution tree and selecting Options; then Run on external console under the Run section. I'm not sure if you can disable this on OSX.