Welcome to Linux Forums!

With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.

Linux Forum ArticlesLinux ForumsLinux Forum DownloadsLinux HostsFree MagazinesJobs
Home|Register|FAQ|Member List|Calendar|Unanswered Posts|Forum Rules|Today's Posts|Advanced Search|
SEARCH FOR IN
Go Back   Linux Forums > Your Distro > Redhat / Fedora Linux Help
Reload this Page remote shutdown of Windows from Linux box
Linux Forums
Linux Forums
Welcome To The Linux Forums!
Welcome to Linux Forums. We pride ourselves in being one of the largest Linux communities on the web, we encourage you to REGISTER on our forums and participate in the community. There are over 150,000 members ready to answer your questions. JOINING US today will allow you to make new posts, get support, send messages to other members and submit downloads to our downloads directory and many other great features!

Redhat / Fedora Linux Help Help and discussion related to Redhat and Fedora Linux.

Closed Thread
 
Thread Tools Display Modes
Old 05-10-2006   #1 (permalink)
Just Joined!
 
Join Date: May 2006
Posts: 2
remote shutdown of Windows from Linux box

I have 2 windows box and one linux box. I want to shutdown the windows
box remotely from linux box.

Any ideas for the above problem ?? I know Samba is one way but dont know how to configure Samba for shutting remote windows.

Every help is appreciated.

Thanks
diffuser78 is offline  
Old 05-10-2006   #2 (permalink)
Bigtomrodinator
 
bigtomrodney's Avatar
 
Join Date: Nov 2004
Location: Sunny South-East of Ireland
Posts: 5,176
Is this for scripting purposes or just to remotely shut down? If it's just access to do it you could use TS/Remote Desktop or even go the vnc route. If it's a case that you are already remoting it and missing your shutdown command, go to start > settings > Windows Security and you will get the ctrl-alt-del option screen.
__________________
In the land of the blind, the night vision users are laughing at the king

Registered Linux user #378740

New members read here / Forum Rules
bigtomrodney is offline  
Old 05-10-2006   #3 (permalink)
Just Joined!
 
Join Date: May 2006
Posts: 2
scripting purpose..I want to automate the process rather than using remote desktop.
Quote:
Originally Posted by bigtomrodney
Is this for scripting purposes or just to remotely shut down? If it's just access to do it you could use TS/Remote Desktop or even go the vnc route. If it's a case that you are already remoting it and missing your shutdown command, go to start > settings > Windows Security and you will get the ctrl-alt-del option screen.
diffuser78 is offline  
Old 07-01-2006   #4 (permalink)
Just Joined!
 
Join Date: Apr 2006
Posts: 15
Arrow here is the python script to shutdown the system remotely

#!/usr/bin/env python
# win32shutdown.py

import win32api
import win32con
import win32netcon
import win32security
import win32wnet


def shutdown(host=None, user=None, passwrd=None, msg=None, timeout=0, force=1,
reboot=0):
""" Shuts down a remote computer, requires NT-BASED OS. """

# Create an initial connection if a username & password is given.
connected = 0
if user and passwrd:
try:
win32wnet.WNetAddConnection2(win32netcon.RESOURCET YPE_ANY, None,
''.join([r'\\', host]), None, user,
passwrd)
# Don't fail on error, it might just work without the connection.
except:
pass
else:
connected = 1
# We need the remote shutdown or shutdown privileges.
p1 = win32security.LookupPrivilegeValue(host, win32con.SE_SHUTDOWN_NAME)
p2 = win32security.LookupPrivilegeValue(host,
win32con.SE_REMOTE_SHUTDOWN_NAME)
newstate = [(p1, win32con.SE_PRIVILEGE_ENABLED),
(p2, win32con.SE_PRIVILEGE_ENABLED)]
# Grab the token and adjust its privileges.
htoken = win32security.OpenProcessToken(win32api.GetCurrent Process(),
win32con.TOKEN_ALL_ACCESS)
win32security.AdjustTokenPrivileges(htoken, False, newstate)
win32api.InitiateSystemShutdown(host, msg, timeout, force, reboot)
# Release the previous connection.
if connected:
win32wnet.WNetCancelConnection2(''.join([r'\\', host]), 0, 0)


if __name__ == '__main__':
# Immediate shutdown.
shutdown('salespc1', 'admin', 'secret', None, 0)
# Delayed shutdown 30 secs.
shutdown('salespc1', 'admin', 'secret', 'Maintenance Shutdown', 30)
# Reboot
shutdown('salespc1', 'admin', 'secret', None, 0, reboot=1)
# Shutdown the local pc
shutdown(None, 'admin', 'secret', None, 0)



enjoy have a nice day
teluguswan is offline  
Old 07-01-2006   #5 (permalink)
Just Joined!
 
Join Date: Apr 2006
Posts: 15
got the link from

http://aspn.activestate.com/ASPN/Coo.../Recipe/360649
teluguswan is offline  
Old 07-27-2007   #6 (permalink)
Just Joined!
 
Join Date: Jul 2007
Posts: 1
Try PowerOff from this page:

PowerOff

Install that on the Windows box as a service with an appropriate password, then test it by telnetting into the box (see chapter 5 of the manual) and shutting down.

Scripting it should be fairly straightforward after that. (You'll need to automate telnet, perhaps by cat'ing a file with the relevant commands to it...)
Msquared is offline  
Old 04-02-2008   #7 (permalink)
Just Joined!
 
Join Date: Apr 2008
Location: Southern California
Posts: 6
You can also shutdown a windows box if you have samba installed.

"net rpc SHUTDOWN -C "some comment here" -f -I x.x.x.x -U user_name%password"

As long as the user you supplied has rights to shutdown the system it will work.

I wrote a bash script that scans our network and turns off all our system that are left on over night. If you are interested.



"#!/bin/bash

wks=(`nmap -sL --dns-servers 10.x.x.x,10.x.x.x 10.x.x.x/22, 10.x.x.x.x/23 grep FQDN|cut -d" " -f2 |grep -v -f serverlist`)

for (( i=0; i < "${#wks[@]}"; i++)); do
net rpc SHUTDOWN -C "This system was left on after hours and is being shutdown" -f -I "${wks[$i]}" -U user_name%password

done"



Basically what the script does is scans the network(s) with nmap, pipes it though grep and cut to get the FQDN. Then "grep -v -f serverlist" is an exclude list of server I don't want shutdown. From there it puts the workstations into an array and turns off each system.

Hope it helps
thronh is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe
Systems Management News, the newspaper for IT systems administration and data center managers!
Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe
The Enterprise Newsweekly
eWeek is the essential technology information source for builders of e-business.
subscribe
Oracle Magazine
Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe
Total Telecom
Total Telecom is "The Economist of the communications industry".
subscribe
More free magazines »



All times are GMT. The time now is 05:18 PM.




© 2000 - 2008 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.2.0