public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: Rebooting a windows 2000 box
@ 2001-08-09 10:59 tplesco
  0 siblings, 0 replies; 17+ messages in thread
From: tplesco @ 2001-08-09 10:59 UTC (permalink / raw)
  To: cygwin

Hi, 

I put Corinna's reboot code into a file named reboot.c but I'm getting an
error. Any help would be appreciated.  Here's a snapshot of my results:

$ make -f reboot.c reboot.exe
reboot.c:11: *** commands commence before first target.  Stop.

-Todd


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Rebooting a windows 2000 box
  2001-08-10  2:32 George Planansky
@ 2001-08-10  2:52 ` Corinna Vinschen
  0 siblings, 0 replies; 17+ messages in thread
From: Corinna Vinschen @ 2001-08-10  2:52 UTC (permalink / raw)
  To: cygwin

On Fri, Aug 10, 2001 at 05:32:31AM -0400, George Planansky wrote:
> > From: Corinna Vinschen <cygwin@cygwin.com>
> > Date: Fri, 10 Aug 2001 09:02:32 +0200
> > 
> > On Fri, Aug 10, 2001 at 01:38:00AM +0200, Norbert Fischer wrote:
> > > Corinna Vinschen wrote:
> > > 
> > > > *#@^%Windows98$%##&@!+
> > > 
> > > What's this?
> > 
> > Cursing.
> > 
> > > 
> > > > Try using the FORCE flag. Change
> > > 
> > > The system trys to shutdown but instead it goes into a crash.
> > 
> > Ok, then somebody else has to look.
> 
> There is already a windows resource shutdown.exe for nt4,
>   c:\NTRESKIT\SHUTDOWN.EXE
> and I would guess the same or modified for win2k.
> Quite capable. Why not just use that?

The problem is 9x/ME, not W2K.

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Rebooting a windows 2000 box
@ 2001-08-10  2:32 George Planansky
  2001-08-10  2:52 ` Corinna Vinschen
  0 siblings, 1 reply; 17+ messages in thread
From: George Planansky @ 2001-08-10  2:32 UTC (permalink / raw)
  To: cygwin

> From: Corinna Vinschen <cygwin@cygwin.com>
> Date: Fri, 10 Aug 2001 09:02:32 +0200
> 
> On Fri, Aug 10, 2001 at 01:38:00AM +0200, Norbert Fischer wrote:
> > Corinna Vinschen wrote:
> > 
> > > *#@^%Windows98$%##&@!+
> > 
> > What's this?
> 
> Cursing.
> 
> > 
> > > Try using the FORCE flag. Change
> > 
> > The system trys to shutdown but instead it goes into a crash.
> 
> Ok, then somebody else has to look.

There is already a windows resource shutdown.exe for nt4,
  c:\NTRESKIT\SHUTDOWN.EXE
and I would guess the same or modified for win2k.
Quite capable. Why not just use that?

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Rebooting a windows 2000 box
  2001-08-09 16:47           ` Norbert Fischer
@ 2001-08-10  0:02             ` Corinna Vinschen
  0 siblings, 0 replies; 17+ messages in thread
From: Corinna Vinschen @ 2001-08-10  0:02 UTC (permalink / raw)
  To: cygwin

On Fri, Aug 10, 2001 at 01:38:00AM +0200, Norbert Fischer wrote:
> Corinna Vinschen wrote:
> 
> > *#@^%Windows98$%##&@!+
> 
> What's this?

Cursing.

> 
> > Try using the FORCE flag. Change
> 
> The system trys to shutdown but instead it goes into a crash.

Ok, then somebody else has to look.

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Rebooting a windows 2000 box
  2001-08-09  9:19         ` Corinna Vinschen
@ 2001-08-09 16:47           ` Norbert Fischer
  2001-08-10  0:02             ` Corinna Vinschen
  0 siblings, 1 reply; 17+ messages in thread
From: Norbert Fischer @ 2001-08-09 16:47 UTC (permalink / raw)
  To: cygwin

Corinna Vinschen wrote:

> *#@^%Windows98$%##&@!+

What's this?

> Try using the FORCE flag. Change

The system trys to shutdown but instead it goes into a crash.

CU

-Polaris-

Polaris@Polaris.Franken.de

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Rebooting a windows 2000 box
  2001-08-09 11:05 Peter Buckley
@ 2001-08-09 11:36 ` tplesco
  0 siblings, 0 replies; 17+ messages in thread
From: tplesco @ 2001-08-09 11:36 UTC (permalink / raw)
  To: cygwin

Doh! It's simple C. 

I used
gcc reboot.c -o reboot.exe
and it works great.

Thanks!

On Thu, Aug 09, 2001 at 02:04:48PM -0400, Peter Buckley wrote:
> I think that reboot.c is not a makefile. You have to use 
> a C-compiler, not "make" to build an executable. You can 
> write a makefile to call the compiler, but make -f is saying 
> that reboot.c is your makefile, and looking at Corinna's 
> code, that definitely is not a makefile. I think you can 
> use gcc to compile, but I am no c-programmer yet :-)
> 
> HTH,
> Peter
> 
> -----Original Message-----
> From: tplesco [ mailto:tod@megachump.com ]
> Sent: Thursday, August 09, 2001 2:01 PM
> To: cygwin@cygwin.com
> Subject: Re: Rebooting a windows 2000 box
> 
> 
> Hi, 
> 
> I put Corinna's reboot code into a file named reboot.c but I'm getting an
> error. Any help would be appreciated.  Here's a snapshot of my results:
> 
> $ make -f reboot.c reboot.exe
> reboot.c:11: *** commands commence before first target.  Stop.
> 
> -Todd
> 
> 
> --
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> Bug reporting:         http://cygwin.com/bugs.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/
> 
> --
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> Bug reporting:         http://cygwin.com/bugs.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/
> 

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: Rebooting a windows 2000 box
@ 2001-08-09 11:22 Darren Shepard
  0 siblings, 0 replies; 17+ messages in thread
From: Darren Shepard @ 2001-08-09 11:22 UTC (permalink / raw)
  To: 'cygwin@cygwin.com'; +Cc: 'tplesco'

>> tplesco <tod@megachump.com> wrote:
| I put Corinna's reboot code into a file named reboot.c but 
| I'm getting an error. Any help would be appreciated.  Here's
| a snapshot of my results:
| 
| $ make -f reboot.c reboot.exe
| reboot.c:11: *** commands commence before first target.  
| Stop.

reboot.c is not a makefile, try just 'make reboot' (yes without the .c)
instead.
--
Darren Shepard

"WorldSecure <Freightliner.com>" made the following
 annotations on 08/09/01 11:10:55
------------------------------------------------------------------------------

[INFO] -- Content Manager:
The information contained in this communication is confidential and intended solely for the use of the individual to whom it is addressed and others authorized to receive it.  If you are not the intended recipient, any disclosure, copying, distribution or taking of any action in reliance on the contents of this information is prohibited. If you have received this communication in error, please immediately notify the sender by phone if possible or via email message.  

==============================================================================


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: Rebooting a windows 2000 box
@ 2001-08-09 11:05 Peter Buckley
  2001-08-09 11:36 ` tplesco
  0 siblings, 1 reply; 17+ messages in thread
From: Peter Buckley @ 2001-08-09 11:05 UTC (permalink / raw)
  To: 'tplesco', cygwin

I think that reboot.c is not a makefile. You have to use 
a C-compiler, not "make" to build an executable. You can 
write a makefile to call the compiler, but make -f is saying 
that reboot.c is your makefile, and looking at Corinna's 
code, that definitely is not a makefile. I think you can 
use gcc to compile, but I am no c-programmer yet :-)

HTH,
Peter

-----Original Message-----
From: tplesco [ mailto:tod@megachump.com ]
Sent: Thursday, August 09, 2001 2:01 PM
To: cygwin@cygwin.com
Subject: Re: Rebooting a windows 2000 box


Hi, 

I put Corinna's reboot code into a file named reboot.c but I'm getting an
error. Any help would be appreciated.  Here's a snapshot of my results:

$ make -f reboot.c reboot.exe
reboot.c:11: *** commands commence before first target.  Stop.

-Todd


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Rebooting a windows 2000 box
  2001-08-09  9:03       ` Norbert Fischer
@ 2001-08-09  9:19         ` Corinna Vinschen
  2001-08-09 16:47           ` Norbert Fischer
  0 siblings, 1 reply; 17+ messages in thread
From: Corinna Vinschen @ 2001-08-09  9:19 UTC (permalink / raw)
  To: cygwin

On Thu, Aug 09, 2001 at 05:56:00PM +0200, Norbert Fischer wrote:
> Corinna Vinschen wrote:
> 
> > No. Try this:
> 
> Hmm, it seems to work, but I can not really test it. If I call it "reboot.exe"
> it doesn't reboot. If I call it "shutdown.exe" it doesn't shutdown.
> If I use the flags ("reboot -r now") I get a pop-up-window "Diese Anwendung
> muss vor Windows beendet werden. Klicken Sie auf OK um zuerst die Anwendung
> und dann Windows zu beenden oder auf Abbrechen um weder die Anwendung
> noch Windows zu beenden". It doesn't matter whether I click at cancel
> or OK, in both cases I get back to Cygwin.

*#@^%Windows98$%##&@!+

Try using the FORCE flag. Change

                        /* EWX_FORCE doesn't work correctly on 9x/ME. */
                        if (GetVersion () < 0x80000000L)
                                force = EWX_FORCE;

to

			force = EWX_FORCE;

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Rebooting a windows 2000 box
  2001-08-09  7:05     ` Corinna Vinschen
@ 2001-08-09  9:03       ` Norbert Fischer
  2001-08-09  9:19         ` Corinna Vinschen
  0 siblings, 1 reply; 17+ messages in thread
From: Norbert Fischer @ 2001-08-09  9:03 UTC (permalink / raw)
  To: cygwin

Corinna Vinschen wrote:

> No. Try this:

Hmm, it seems to work, but I can not really test it. If I call it "reboot.exe"
it doesn't reboot. If I call it "shutdown.exe" it doesn't shutdown.
If I use the flags ("reboot -r now") I get a pop-up-window "Diese Anwendung
muss vor Windows beendet werden. Klicken Sie auf OK um zuerst die Anwendung
und dann Windows zu beenden oder auf Abbrechen um weder die Anwendung
noch Windows zu beenden". It doesn't matter whether I click at cancel
or OK, in both cases I get back to Cygwin.

If I start reboot without Cygwin I get the message that cygwin.dll ist
missed.

CU

-Polaris-

Polaris@Polaris.Franken.de

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Rebooting a windows 2000 box
  2001-08-09  6:03   ` Norbert Fischer
@ 2001-08-09  7:05     ` Corinna Vinschen
  2001-08-09  9:03       ` Norbert Fischer
  0 siblings, 1 reply; 17+ messages in thread
From: Corinna Vinschen @ 2001-08-09  7:05 UTC (permalink / raw)
  To: cygwin

On Thu, Aug 09, 2001 at 03:01:00PM +0200, Norbert Fischer wrote:
> Corinna Vinschen wrote:
> 
> > I wrote the following tiny code in 1998. If you call it `shutdown.exe'
> > it will shutdown, call it `reboot.exe' and it will reboot. Otherwise
> > use the flags.
> 
> Did you write it especially for WinNT/2000 ?

Yes.

> Is it complicated to rewrite it for Win98 ?

No. Try this:

================================================================================
/*
 * shutdown.c: implementation of shutdown(1) as part of a Cygwin environment
 *
 * Copyright 1998,2001  Corinna Vinschen,
 * bug reports to  cygwin@cygwin.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <getopt.h>

#include <windows.h>

static char *SCCSid = "@(#)shutdown V1.1, Corinna Vinschen, " __DATE__ "\n";

char *myname;

int usage(void)
{
	fprintf(stderr, "usage: %s [-fr] secs|\"now\"\n", myname);
	return 1;
}

BOOL (*openprocesstoken)(HANDLE,DWORD,PHANDLE);
BOOL (*adjusttokenprivileges)(HANDLE,BOOL,PTOKEN_PRIVILEGES,DWORD,PTOKEN_PRIVILEGES,PDWORD);
BOOL (*lookupprivilegevalue)(LPCTSTR,LPCTSTR,PLUID);

int setprivs(void)
{
	HANDLE token;
	TOKEN_PRIVILEGES privs;
	HMODULE adv;

	/* Privileges are not supported on 9x/ME. */
	if (GetVersion () >= 0x80000000L)
		return 0;

	if (! (adv = LoadLibrary ("advapi32.dll"))) {
		int ret = GetLastError();
		fprintf(stderr, "%s: can't load advapi32.dll\n", myname);
		return 1;
	}
	if (! (lookupprivilegevalue = (BOOL(*)(LPCTSTR,LPCTSTR,PLUID))
			      GetProcAddress (adv, "LookupPrivilegeValueA"))) {
		int ret = GetLastError();
		fprintf(stderr, "%s: can't load symbol from advapi32.dll\n",
			myname);
		return 1;
	}
	if (! (openprocesstoken = (BOOL(*)(HANDLE,DWORD,PHANDLE))
			      GetProcAddress (adv, "OpenProcessToken"))) {
		int ret = GetLastError();
		fprintf(stderr, "%s: can't load symbol from advapi32.dll\n",
			myname);
		return 1;
	}
	if (! (adjusttokenprivileges = (BOOL(*)(HANDLE,BOOL,PTOKEN_PRIVILEGES,
						DWORD,PTOKEN_PRIVILEGES,PDWORD))
			      GetProcAddress (adv, "AdjustTokenPrivileges"))) {
		int ret = GetLastError();
		fprintf(stderr, "%s: can't load symbol from advapi32.dll\n",
			myname);
		return 1;
	}

	privs.PrivilegeCount = 1;
	lookupprivilegevalue(NULL, SE_SHUTDOWN_NAME, &privs.Privileges[0].Luid);
	privs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
	if (! openprocesstoken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES,
			       &token)) {
		int ret = GetLastError();
		fprintf(stderr, "%s: insufficient privileges\n", myname);
		return 1;
	}
	if (! adjusttokenprivileges(token, FALSE, &privs, 0, NULL, NULL)) {
		fprintf(stderr, "%s: insufficient privileges\n", myname);
		return 1;
	}
	return 0;
}

int main(int argc, char **argv)
{
	int c;
	unsigned int secs;
	int action = EWX_POWEROFF;
	int force = 0;


	if ((myname = strrchr(argv[0], '/')) ||
		(myname = strrchr(argv[0], '\\')))
		++myname;
	else
		myname = argv[0];
	if (strrchr(myname, '.'))
		*strrchr(myname, '.') = '\0';
	if (! strcmp(myname, "reboot"))
		action = EWX_REBOOT;
	while ((c = getopt(argc, argv, "fr")) != EOF)
		switch (c) {
		case 'f':
			/* EWX_FORCE doesn't work correctly on 9x/ME. */
			if (GetVersion () < 0x80000000L)
				force = EWX_FORCE;
			break;
		case 'r':
			action = EWX_REBOOT;
			break;
		default:
			return usage();
		}
	if (optind >= argc)
		return usage();
	if (! strcmp(argv[optind], "now"))
		secs = 0;
	else if (! isdigit(argv[optind][0])) {
		usage();
		fprintf(stderr, "%s: secs must be numerical or the word \"now\"\n",
						myname);
		return 2;
	} else
		secs = atoi(argv[optind]);

	if (setprivs())
		return 3;

	printf("WARNING!!! System is going down ");
	if (secs)
		printf("in %d seconds\n", secs);
	else
		printf("NOW\n");
	while (secs)
		secs = sleep(secs);
	if (! ExitWindowsEx(action | force, 0)) {
		fprintf(stderr, "%s: insufficient privileges\n", myname);
		return 3;
	}
	return 0;
}
================================================================================

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Rebooting a windows 2000 box
  2001-08-01  0:34 ` Corinna Vinschen
  2001-08-01  2:50   ` Keith Starsmeare
@ 2001-08-09  6:03   ` Norbert Fischer
  2001-08-09  7:05     ` Corinna Vinschen
  1 sibling, 1 reply; 17+ messages in thread
From: Norbert Fischer @ 2001-08-09  6:03 UTC (permalink / raw)
  To: cygwin

Corinna Vinschen wrote:

> I wrote the following tiny code in 1998. If you call it `shutdown.exe'
> it will shutdown, call it `reboot.exe' and it will reboot. Otherwise
> use the flags.

Did you write it especially for WinNT/2000 ?
Under Win98 it doesn't work.
Is it complicated to rewrite it for Win98 ?

CU

-Polaris-

Polaris@Polaris.Franken.de

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Rebooting a windows 2000 box
  2001-07-31 21:25 Michael A . Behr
  2001-08-01  0:34 ` Corinna Vinschen
@ 2001-08-01  5:17 ` Prentis Brooks
  1 sibling, 0 replies; 17+ messages in thread
From: Prentis Brooks @ 2001-08-01  5:17 UTC (permalink / raw)
  To: Michael A . Behr; +Cc: cygwin

The best bet would be shutdown.exe from the Resource Kit.  Not sure if there
are any free/shareware solutions out there

On Wed, 1 Aug 2001, Michael A . Behr wrote:

> Hello all,
>
> I need to reboot a win2k box from remote.  I'm using ssh to connect to
> the machine...  is there a command that I can send through cygwin to
> reboot the machine?
>
> Thanks,
>
>

Prentis Brooks	| prentis@aol.net | 703-265-0914 | AIM: PrentisB
System Administrator - Web Infrastructure & Security

       A knight is sworn to valor.  His heart knows only virtue.  His blade
       defends the helpless.  His word speaks only truth.  His wrath undoes the
       wicked. - the old code of Bowen, last of the dragonslayers


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Rebooting a windows 2000 box
  2001-08-01  0:34 ` Corinna Vinschen
@ 2001-08-01  2:50   ` Keith Starsmeare
  2001-08-09  6:03   ` Norbert Fischer
  1 sibling, 0 replies; 17+ messages in thread
From: Keith Starsmeare @ 2001-08-01  2:50 UTC (permalink / raw)
  To: Corinna Vinschen

----- Original Message ----- 
From: "Corinna Vinschen" <cygwin@cygwin.com>
To: <cygwin@cygwin.com>
Sent: Wednesday, August 01, 2001 8:34 AM
Subject: Re: Rebooting a windows 2000 box


> I wrote the following tiny code in 1998. If you call it `shutdown.exe'
> it will shutdown, call it `reboot.exe' and it will reboot. Otherwise
> use the flags.

What a great little program. Thanks for sharing!

Keith


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Rebooting a windows 2000 box
  2001-07-31 21:25 Michael A . Behr
@ 2001-08-01  0:34 ` Corinna Vinschen
  2001-08-01  2:50   ` Keith Starsmeare
  2001-08-09  6:03   ` Norbert Fischer
  2001-08-01  5:17 ` Prentis Brooks
  1 sibling, 2 replies; 17+ messages in thread
From: Corinna Vinschen @ 2001-08-01  0:34 UTC (permalink / raw)
  To: cygwin

> Hello all,
> 
> I need to reboot a win2k box from remote.  I'm using ssh to connect to
> the machine...  is there a command that I can send through cygwin to
> reboot the machine?

I wrote the following tiny code in 1998. If you call it `shutdown.exe'
it will shutdown, call it `reboot.exe' and it will reboot. Otherwise
use the flags.

Hope, that helps,
Corinna

------------------------------ SNIP -------------------------------
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <getopt.h>

#include <windows.h>

int reboot = FALSE;
int force = FALSE;

char *myname;

int usage(void)
{
	fprintf(stderr, "usage: %s [-fr] secs|\"now\"\n", myname);
	return 1;
}

int main(int argc, char **argv)
{
	int c;
	unsigned int secs;
	HANDLE token;
	TOKEN_PRIVILEGES privs;

	if ((myname = strrchr(argv[0], '/')) ||
		(myname = strrchr(argv[0], '\\')))
		++myname;
	else
		myname = argv[0];
	if (strrchr(myname, '.'))
		*strrchr(myname, '.') = '\0';
	if (! strcmp(myname, "reboot"))
		reboot = TRUE;
	while ((c = getopt(argc, argv, "fr")) != EOF)
		switch (c) {
		case 'f':
			force = TRUE;
			break;
		case 'r':
			reboot = TRUE;
			break;
		default:
			return usage();
		}
	if (optind >= argc)
		return usage();
	if (! strcmp(argv[optind], "now"))
		secs = 0;
	else if (! isdigit(argv[optind][0])) {
		usage();
		fprintf(stderr, "%s: secs must be numerical or the word \"now\"\n",
						myname);
		return 2;
	} else
		secs = atoi(argv[optind]);

	privs.PrivilegeCount = 1;
	LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &privs.Privileges[0].Luid);
	privs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
	if (! OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token)) {
		int ret = GetLastError();
		fprintf(stderr, "%s: insufficient privileges\n", myname);
		return 3;
	}
	if (! AdjustTokenPrivileges(token, FALSE, &privs, 0, NULL, NULL)) {
		fprintf(stderr, "%s: insufficient privileges\n", myname);
		return 3;
	}


	printf("WARNING!!! System is going down ");
	if (secs)
		printf("in %d seconds\n", secs);
	else
		printf("NOW\n");
	while (secs)
		secs = sleep(secs);
	if (! InitiateSystemShutdown(NULL, NULL, 0, force, reboot)) {
		fprintf(stderr, "%s: insufficient privileges\n", myname);
		return 3;
	}
	return 0;
}

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: Rebooting a windows 2000 box
@ 2001-07-31 21:41 Neil Lunn
  0 siblings, 0 replies; 17+ messages in thread
From: Neil Lunn @ 2001-07-31 21:41 UTC (permalink / raw)
  To: 'Michael A . Behr', cygwin

More of a Windows Question, Try Google or elsewhere.

A quick google search reveals:

http://crv.mp3car.com/shutdown.html

I belive that there is, was whatever this or another utility in the NT
Resource kit.

--Neil

>-----Original Message-----
>From: Michael A . Behr [ mailto:mabehr@alum.mit.edu ]
>Sent: Wednesday, August 01, 2001 2:26 PM
>To: cygwin@cygwin.com
>Subject: Rebooting a windows 2000 box
>
>
>Hello all,
>
>I need to reboot a win2k box from remote.  I'm using ssh to connect to
>the machine...  is there a command that I can send through cygwin to
>reboot the machine?
>
>Thanks,
>
>-- 
>-M.A.Behr
>
>ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
>o       Michael Behr         o                                  o
>o    Home: 617.723.9236      o "I laugh in the face of danger!  o
>o   Mobile: 617.835.8494     o Then I hide until it goes away." o
>o email: mabehr@alum.mit.edu o                                  o
>ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
>
>--
>Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>Bug reporting:         http://cygwin.com/bugs.html
>Documentation:         http://cygwin.com/docs.html
>FAQ:                   http://cygwin.com/faq/
>

__________________________________________________________________________
Please Note :
Only  the intended recipient is authorised to access or use this e-mail.  If
you are not the intended recipient,
please delete this e-mail and notify the sender immediately.   The contents
of this e-mail are the writer's 
opinion and are not necessarily endorsed by the Gunz Companies unless
expressly stated.

We use virus scanning software but exclude all liability for viruses or
similar in any attachment.



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Rebooting a windows 2000 box
@ 2001-07-31 21:25 Michael A . Behr
  2001-08-01  0:34 ` Corinna Vinschen
  2001-08-01  5:17 ` Prentis Brooks
  0 siblings, 2 replies; 17+ messages in thread
From: Michael A . Behr @ 2001-07-31 21:25 UTC (permalink / raw)
  To: cygwin

Hello all,

I need to reboot a win2k box from remote.  I'm using ssh to connect to
the machine...  is there a command that I can send through cygwin to
reboot the machine?

Thanks,

-- 
-M.A.Behr

ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
o       Michael Behr         o                                  o
o    Home: 617.723.9236      o "I laugh in the face of danger!  o
o   Mobile: 617.835.8494     o Then I hide until it goes away." o
o email: mabehr@alum.mit.edu o                                  o
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2001-08-10  2:52 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-09 10:59 Rebooting a windows 2000 box tplesco
  -- strict thread matches above, loose matches on Subject: below --
2001-08-10  2:32 George Planansky
2001-08-10  2:52 ` Corinna Vinschen
2001-08-09 11:22 Darren Shepard
2001-08-09 11:05 Peter Buckley
2001-08-09 11:36 ` tplesco
2001-07-31 21:41 Neil Lunn
2001-07-31 21:25 Michael A . Behr
2001-08-01  0:34 ` Corinna Vinschen
2001-08-01  2:50   ` Keith Starsmeare
2001-08-09  6:03   ` Norbert Fischer
2001-08-09  7:05     ` Corinna Vinschen
2001-08-09  9:03       ` Norbert Fischer
2001-08-09  9:19         ` Corinna Vinschen
2001-08-09 16:47           ` Norbert Fischer
2001-08-10  0:02             ` Corinna Vinschen
2001-08-01  5:17 ` Prentis Brooks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).