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 3066 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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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: 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...
| |