Since a month or two i'm learning and programming with C#.
(i'm using Visual Studio 2005 version 8.0 beta2 with .NET framework 2.0 and stuff,
the newest, got it from my dad be he only uses C++ and C and "says" he thinks of going over to C#)
I'm living on my own a sometimes my brother comes over.
(we've created a network between our pc's)
and sometimes he stays over but forgets to shutdown his pc, or has the feeling he'll be back soon to shut it down.
well anyway, I though of a programm but it doesn't work.
maybe it's the privilege's or i'm not experienced enough and don't know what code I miss (probably)
(we are now using a remote pc control program but it kind of spoils all the fun (and it's a demo) )
it currentley looks like this:
//===========================================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace RemoteShutdown
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//====================================================================================
[DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool InitiateSystemShutdown(
string lpMachineName,
string lpMessage,
uint dwTimeout,
bool bForceAppsClosed,
bool bRebootAfterShutdown);
//====================================================================================
private void button1_Click(object sender, EventArgs e)
{
InitiateSystemShutdown("\\brother-pc", "ByeBye!!", 2, false, false);
\\i've seen a network programm which used "\\\\internet or network pc name here"<-- four \ thingy's
\\but I don't think that's the problem (I tried)
}
}
}
and maybe someone can send/post a little code that alows me to search pc's on the network (so I can add my pc I use at work and "eventually" (<-- yeah sure) create my own remote control app
the demo version expires in 27 days
would be nice if I had an answer for the demo expires.
many, many, many thanks in advance.
Kind Regards : Me

Remote Shutdown Problem (i'm C# Noob :-P)
freeaaron
InitiateShutdown(@"\\pcname","Bye bye",2,false,false);
Fix that and also check if you have permissions to remote shutdown the network computer you're trying to.
Jan Heppen
but thanks for the idea
cheers,
Kiyac
GarryB
Hi,
This is just an idea. In command prompt you could shutdown a computer remotely by calling a shutdown command.
shutdown computername -s
this command shutdowns the computer remotely across the network. If you have administrative rights. Maybe you could try executing this in your program, try using the Syste.Diagnostics.Process class to execute this command...
BTW, you might want to do this manually first, coz it might not work. This feature is just present in WindowsXP upwards...
cheers,
Paul June A. Domag