hai friends,
Iam developing a application using .NET remoting ,in which it shuts down,logs off , restart , locks remote PC.i tried to use windows ExwindowsEXAPI for shutdown,logoff , restart and SetSuspendState for lock PC and the later worked perfectly but the problem is ExwindowsEx only Logsoff the PC and shutdown and restart is not working .Although i achieved the result using shutdown.exe ,but iam not convinced,so could anyone say what may be the problem.
server code -
-
-
-
[DllImport("user32.dll")]
-
public static extern int ExitWindowsEx(uint uflag,uint reson);
-
-
public void shutdown_server(uint f)
-
{
-
ExitWindowsEx(f,0);
-
}
-
-
public void shut_server_exe(string arg)
-
{
-
-
System.Diagnostics.Process.Start("C:/shutdown.exe", arg);
-
}
-
-
[DllImport("Powrprof.dll")]
-
public static extern bool SetSuspendState(bool h, bool g, bool i);
-
public void standby()
-
{
-
SetSuspendState(false, false, false);
-
}
-
-
-
client code -
-
private void logOffToolStripMenuItem_Click(object sender, EventArgs e)
-
{
-
try
-
{
-
serverclass obj = (serverclass)Activator.GetObject(
-
typeof(serverclass),
-
"http://" + IP + ":1234/serverclass.soap");
-
obj.shutdown_server(0);
-
}
-
catch (Exception err)
-
{
-
MessageBox.Show(err.Message);
-
disconnect();
-
}
-
}
-
-
private void turnOffToolStripMenuItem_Click(object sender, EventArgs e)
-
{
-
try
-
{
-
serverclass obj = (serverclass)Activator.GetObject(
-
typeof(serverclass),
-
"http://" + IP + ":1234/serverclass.soap");
-
//obj.DoExitWin(2);
-
// obj.shutdown_server(8);
-
obj.shut_server_exe("/L /C /Y");
-
}
-
catch (Exception err)
-
{
-
MessageBox.Show(err.Message);
-
disconnect();
-
}
-
}
-
-
private void restartToolStripMenuItem_Click(object sender, EventArgs e)
-
{
-
try
-
{
-
serverclass obj = (serverclass)Activator.GetObject(
-
typeof(serverclass),
-
"http://" + IP + ":1234/serverclass.soap");
-
// obj.shutdown_server(2);
-
obj.shut_server_exe("/L /R /C /Y");
-
}
-
catch (Exception err)
-
{
-
MessageBox.Show(err.Message);
-
disconnect();
-
}
-
}
-
-
private void lockPCToolStripMenuItem_Click(object sender, EventArgs e)
-
{
-
try
-
{
-
-
serverclass obj = (serverclass)Activator.GetObject(
-
typeof(serverclass),
-
"http://" + IP + ":1234/serverclass.soap");
-
obj.standby();
-
}
-
catch (Exception err)
-
{
-
MessageBox.Show(err.Message);
-
disconnect();
-
}
-
}
-
thanks friends
1 3063 Plater 7,872
Recognized Expert Expert
Pretty sure using the shutdown.exe is a good way to do it, but for remote PCs the shutdown.exe must be using some kind of commands to do it, and those should exist in the win32 APIs somewhere (RPC call maybe?)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Jonathan Heath |
last post by:
Hi all,
I have created an ASP script that enters data into an Access Database.
My problem is that I'd like this script to run when the computer is shutdown
or the user logs off.
I think this would be simple enough if the ASP didn't have any user input,
but it does.
|
by: Tim Werth |
last post by:
Is there an attribute or property that I can set in my AssemblyInfo.cs that
is used to setup my COM+ application so that I can set the "Minutes until
idle shutdown" of the app to something other than the 3 minute default?
I am using others like:
ApplicationName
ApplicationActivation
ApplicationAccessControl
but I can't find one to set the idle shutdown.
|
by: Senthil |
last post by:
Hi,
I would like to know the code for reboot and shutdown windows xp
professional using VB.Net.
thanx
Senthil
|
by: Bill Sonia |
last post by:
I've written a Windows Service to send e-mails on events like OnStart,
OnStop, OnShutDown using System.Web.Mail. It works for everything but
OnShutdown. My guess is that for OnShutDown, once my send mail code is
executed, other necessary Windows Services have been terminated before
it can actually send the mail. I've updated my
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services registry
DependOnService value including SMPTSVC and...
|
by: carbon_dragon |
last post by:
Ok, so here is the problem. I'm working on a headless server program
implemented as a .NET C# Console project. There is a UPS mounted to
this server (though not a windows compliant UPS). I can only talk to
the UPS over a special device driver.
Through this device driver I can detect that the UPS is going to notify
Windows 2000 server to shut down. So I start doing a graceful
termination. But Windows shuts down pretty quickly and there...
| |
by: Brian Worth |
last post by:
I have just upgraded from VB 4.0 to VB .NET 2002. One program under VB 4.0
was able to shut down or restart the (windows XP) machine using a series of
API calls. (Getlasterror, GetCurrentProcess, OpenProcessToken,
LookupPrivilegeValue, AdjustTokenPrivilegese, ExitWindowsEx.
I am trying to avoid using any API calls if possible and to use managed code
instead. I couldn't find any easy way of doing this but searching the
Internet with...
|
by: Andrew |
last post by:
I have ASP.NET 2.0 application. I'm running some initialization code in
Application_Start() in Global.asax. If this code fails I would like to
shutdown the application completely. Meaning no page, or an error page is
returned to the user. I've tried HostingEnvironment.InitiateShutdown() but
it's async and still returns a page to the user. According to msdn this
method is equivalent to ApplicationManager.ShutdownApplication()...
|
by: Sin Jeong-hun |
last post by:
I created a windows form application. It has a Threading.Timer and when
the timer ticks it does some work and show a popup window.
The problem is that while this program is running if the user tries to
shutdown Windows, my application doesn't quit and neither does
Windows. Of course, if the user first click of my application and
then tries to shutdown, there is no problem.
To solve this problem, I overrode WndProc of the main form,...
|
by: IdleBrain |
last post by:
Gurus,
I am trying to delay Windows Shutdown/Restart to perfrom cleanup and I
am using the following code:
protected override void WndProc(ref Message ex)
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |