Computer And Technologies

Computer And Technologies: Window
Showing posts with label Window. Show all posts
Showing posts with label Window. Show all posts

Wednesday, 6 May 2009

SCCS - (Source Code Control System)

The following commands assume an SCCS repository in /sccs.


----------------------------------------------------------------------------------

To get a read only copy of a file:

get /sccs/migrate/scripts/s.

NOTE: You can get multiple files using standard Unix wildcard

----------------------------------------------------------------------------------

To get an editable copy of a file:

get -e /sccs/migrate/scripts/s.

-----------------------------------------------------------------------------------

To check edited copy into repository:

delta /sccs/migrate/scripts/s.

NOTE: Please put in a comment when prompted.
Also, the delta command removes the file from your directory so you have to
get it again if you want to run it.

----------------------------------------------------------------------------------

To get history of changes:

prs /sccs/migrate/scripts/s.

----------------------------------------------------------------------------------

To compare two revisions of a file (Example rev 1.6 and 1.7):

sccsdiff -r1.6 -r1.7 /sccs/migrate/scripts/s.

-----------------------------------------------------------------------------------

To add a new file:

admin -i -y"COMMENT" /sccs/migrate/scripts/s.

The admin does not remove it from your directory.
However, the unexpanded keywords are still in the file so it appears to
be an editable copy.

Backing up the CVS Repository - (CVSNT-Window)

One the easiest ways in which to backup the CVS Repository on Windows is to schedule a task that runs under and known account. Put the following into a batch file and run it from the schedule:
net stop CVS
xcopy d:\cvsrepo \\server\cvsbackup /Q /S /C /H /R /O /Y
net start CVS

Logging into CVS / Setting CVSROOT - (CVSNT-Window)

Now let's cover what is possible the most difficult component of CVSNT and that is security and adding users. Please be aware that as I write this section of the documentation, I still have a tremendous amount to learn about security within CVSNT. I am only writing this section with what I know and how to get logged on using a local area network. If you are connecting your CVS repository to the Internet, please be aware that there are security problems with the :pserver: protocol. As I learn more about security with CVSNT, I will continue in updating this section of the documentation.

Using a Local Version of CVS

In some cases, you may be developing on the same machine as the CVS server. In this case, you can simply set the CVSROOT environment variable to the absolute path of the CVS Repository. For example:
C:\> set cvsroot=c:\cvsrepo\test

C:\> cvs ls -l -R

Listing modules on server

Directory CVSROOT

checkoutlist 1.1 Fri Jan 23 16:19:24 2004
commitinfo 1.1 Fri Jan 23 16:19:24 2004
config 1.1 Fri Jan 23 16:19:24 2004
cvsrc 1.1 Fri Jan 23 16:19:24 2004
cvswrappers 1.1 Fri Jan 23 16:19:24 2004
editinfo 1.1 Fri Jan 23 16:19:24 2004
historyinfo 1.1 Fri Jan 23 16:19:24 2004
loginfo 1.1 Fri Jan 23 16:19:24 2004
modules 1.1 Fri Jan 23 16:19:24 2004
notify 1.1 Fri Jan 23 16:19:24 2004
postcommit 1.1 Fri Jan 23 16:19:24 2004
rcsinfo 1.1 Fri Jan 23 16:19:24 2004
taginfo 1.1 Fri Jan 23 16:19:24 2004
verifymsg 1.1 Fri Jan 23 16:19:24 2004

Directory CVSROOT/Emptydir
Using the :pserver: Protocol
This section discusses how to add CVS users. Keep in mind that adding users to CVS is only required if you are using the :pserver: protocol. If your users are all on MS Windows PC's, this is not recommended since it has inherent security flaws. It would be better to use either SSPI or :ntserver: (keep in mind however that :ntserver: is being phased out now) because these protocols integrate much better with Windows NT. If you do plan on using the SSPI protocol, then you can skip this discussion of how to add and manage users.

To start, open a command window and do the following - (replace all items with the real values from your system) :

NOTE: When using the :ntserver: protocol, the computer name cannot be entered as "localhost", it must be the real name of the computer.

C:\> set cvsroot=:pserver:@:/TEST
The following example, I will loging to CVS using the :pserver: protocol. The CVS server is named bartman and my user name is jhunter. Keep in mind that I needed to first create the local user, jhunter, on the CVS host. (Which in this example is named bartman.)
C:\> set cvsroot=:pserver:jhunter@bartman:/TEST

C:\> cvs login
(Logging in to jhunter@bartman)
CVS password: *******
To logout of the CVS user, use the following:
C:\> cvs logout
(Logging out of jhunter@bartman)
Using Other Protocols
C:\> set cvsrot=:sspi:jhunter@bartman:/test

C:\> cvs login
(Logging in to jhunter@bartman)
CVS password:**********

C:\> cvs logout
(Logging out of jhunter@bartman)

C:\> set cvsrot=:local:jhunter@bartman:/test

C:\> cvs login
(Logging in to jhunter@bartman)
CVS password:**********

C:\> cvs logout
(Logging out of jhunter@bartman)

Logging into CVS / Setting CVSROOT - (CVSNT-Window)

Now let's cover what is possible the most difficult component of CVSNT and that is security and adding users. Please be aware that as I write this section of the documentation, I still have a tremendous amount to learn about security within CVSNT. I am only writing this section with what I know and how to get logged on using a local area network. If you are connecting your CVS repository to the Internet, please be aware that there are security problems with the :pserver: protocol. As I learn more about security with CVSNT, I will continue in updating this section of the documentation.

Using a Local Version of CVS

In some cases, you may be developing on the same machine as the CVS server. In this case, you can simply set the CVSROOT environment variable to the absolute path of the CVS Repository. For example:
C:\> set cvsroot=c:\cvsrepo\test

C:\> cvs ls -l -R

Listing modules on server

Directory CVSROOT

checkoutlist 1.1 Fri Jan 23 16:19:24 2004
commitinfo 1.1 Fri Jan 23 16:19:24 2004
config 1.1 Fri Jan 23 16:19:24 2004
cvsrc 1.1 Fri Jan 23 16:19:24 2004
cvswrappers 1.1 Fri Jan 23 16:19:24 2004
editinfo 1.1 Fri Jan 23 16:19:24 2004
historyinfo 1.1 Fri Jan 23 16:19:24 2004
loginfo 1.1 Fri Jan 23 16:19:24 2004
modules 1.1 Fri Jan 23 16:19:24 2004
notify 1.1 Fri Jan 23 16:19:24 2004
postcommit 1.1 Fri Jan 23 16:19:24 2004
rcsinfo 1.1 Fri Jan 23 16:19:24 2004
taginfo 1.1 Fri Jan 23 16:19:24 2004
verifymsg 1.1 Fri Jan 23 16:19:24 2004

Directory CVSROOT/Emptydir
Using the :pserver: Protocol
This section discusses how to add CVS users. Keep in mind that adding users to CVS is only required if you are using the :pserver: protocol. If your users are all on MS Windows PC's, this is not recommended since it has inherent security flaws. It would be better to use either SSPI or :ntserver: (keep in mind however that :ntserver: is being phased out now) because these protocols integrate much better with Windows NT. If you do plan on using the SSPI protocol, then you can skip this discussion of how to add and manage users.

To start, open a command window and do the following - (replace all items with the real values from your system) :

NOTE: When using the :ntserver: protocol, the computer name cannot be entered as "localhost", it must be the real name of the computer.

C:\> set cvsroot=:pserver:@:/TEST
The following example, I will loging to CVS using the :pserver: protocol. The CVS server is named bartman and my user name is jhunter. Keep in mind that I needed to first create the local user, jhunter, on the CVS host. (Which in this example is named bartman.)
C:\> set cvsroot=:pserver:jhunter@bartman:/TEST

C:\> cvs login
(Logging in to jhunter@bartman)
CVS password: *******
To logout of the CVS user, use the following:
C:\> cvs logout
(Logging out of jhunter@bartman)
Using Other Protocols
C:\> set cvsrot=:sspi:jhunter@bartman:/test

C:\> cvs login
(Logging in to jhunter@bartman)
CVS password:**********

C:\> cvs logout
(Logging out of jhunter@bartman)

C:\> set cvsrot=:local:jhunter@bartman:/test

C:\> cvs login
(Logging in to jhunter@bartman)
CVS password:**********

C:\> cvs logout
(Logging out of jhunter@bartman)

Creating a CVS Repository - (CVSNT-Window)

  1. First, open the CVSNT Control Panel applet. The applet is located in the Control Panel and is generally called CVS for NT (the green fish). A full description of the CVSNT Control Panel applet is described above (in the Post Installation Steps section).

  2. Then, check to make sure that the CVS Service is not running. If it is, click on the Stop button to stop the service.

  3. Now you will need to set the Repository Prefix. Go to the "Repositories" tab. It will initially look like this:

    Check the checkbox for the Repository Prefix and browse to the directory you created c:\cvsrepos using the ellipsis button.

    After successfully setting the Repository Prefix and selecting the Repository Prefix directory, your screen should look like the following:

  4. Now let's create our first CVS repository. To do this, we will stay on the same screen we were on (above) and click the "Add" button. This will bring up the "Enter path to new root" dialog. Fill this dialog box in as follows:

    After hitting the "OK" button, your screen should look like the following:

  5. Now go to the "Advanced" tab and view the checkboxes. Initially, this screen should look like the following:

    In this screen, first change the Temporary Directory to C:\cvstemp.

    Now go back to the protocol support. Here you have three options to set/clear:

    • Support ntserver protocol. This is what CVSNT has been using for NT connectivity, but it is being phased out in favor of the SSPI protocol, which works over TCP/IP.
    • Impersonation enabled. This setting allows CVSNT to operate in the guise of the user actually doing the command. So with this flag on you can use file system permissions.
    • Use local users instead of domain. Use this if you don't have a domain to authenticate against. Note that in this mode your users must have valid accounts on the server PC itself.

    For these tests check all checkboxes (except for "Don't resolve client names"). You can later go back and change these settings at a later time.

    Your "Advanced" screen should now look like the following:

    NOTE: You MUST click the "Apply" button. This is important. Nothing will happen unless you hit the Apply button. Note that after you have done this, the "Apply" button is disabled.

  6. Finally, go back to the "Service Status" tab and start the CVS Service service. If your service successfully starts, your screen should look like the following:

Installing WinCVS (CVSNT-Window)

Overview
CVS is the Concurrent Versions System, the dominant open-source network-transparent version control system. CVS is useful for everyone from individual developers to large, distributed teams:

This articles provides an overview of the steps required to install and configure CVSNT, version 2.0.14.

Downloading CVSNT
You can download the Windows version of CVS, named CVSNT, from the following site:
    Windows version of the CVS: http://www.cvsnt.org
Here are several other CVS website that you may find useful:
    CVS Domain Home Page:       http://www.cvshome.org
GUI front-end for CVS: http://www.wincvs.org
Java client: http://www.jcvs.org
Installing the CVSNT Software
IMPORTANT: Use a local disk! CVSNT does not work properly unless the repository files are located on a disk on the local PC. Don't try to use a network drive or a mapped disk (not even a mapped disk aimed at the local PC)! It will not work and there are numerous reasons, here is one

CVSNT runs as a service and thus acts as the SYSTEM user account. This account has no permissions on the network and so cannot access the files if they are on a remote server. In fact if the files are on the same PC does not help either if they are accessed using the network via an UNC path. The dive is still considered to be on the network where SYSTEM cannot operate. So don't even try to create such a configuration!

Before starting the CVSNT installation, create two directories on the target machine:

c:\cvsrepo
c:\cvstemp

NOTE: The important point here is that the disk where the repository is located on is NTFS. Where CVSNT itself is installed in not important, it can be on FAT32 or NTFS or whatever. In this document I assume that C: has been used.

NOTE: The cvstemp directory must NOT be located in either c:\WINNT\Temp or anywhere in the "C:\Documents and Settings" tree because these locations have imposed restrictions on user access in Win2000 and Win-XP!

Now run the downloaded CVSNT setup file. For the purpose of this example, I will choose to install CVSNT to the path c:\cvsnt

The following is a set of screen shots along with detailed information on how to install the CVSNT software product.

Welcome Screen


License Agreement

Install Directory Selection

As stated in the introduction, I will be installing CVSNT to c:\cvsnt. I generally try to avoid directory names with spaces.


Anti-virus Software Warning

You version of CVSNT may prompt you with another screen indicating that Anti-virus software can cause corruption in your repository. There will be a checkbox that you have to select saying that I understand before you can continue the installation.


Installation Component Selection Screen

When installing CVSNT, all of the components may not be required to install it as a server. Make sure to check all components in this screen (as shown below).


Shortcut Folder Selection

Task Selection Screen

On some versions of CVSNT, some of the tasks may not be selected. Make sure that all tasks are selected (as shown in the above screen).


Ready to Install Screen

Installation Progress Screen

Installation is Complete!

Post Installation Steps
  1. Note that there are times where the installer may complain that it was not table to set the PATH environment variable at the end of the installation. If this happens, you can simply open the Control Panel and double-click the System icon. Go to the Environment tab (for Windows 2000) or the Advanced tab (for Windows XP). From there you will need to set the System variable path to include c:\cvsnt; to the begining of the PATH variable and save it (Apply).

    Location of this setting page varies between NT4, Windows 2000, and XP. You may have to search around a bit.

  2. Ensure that the CVSNT Control Panel Configuration applet was installed. To do this, open your Control Panel and look for the CVSNT applet (the green fish).

    If you have problems locating the CVSNT Control Panel applet, it might be because one or several of a few system .DLL's are missing. These libraries were suppose to be installed by the CVSNT installer, but sometimes this step fails. The files you will need can be extracted from the binary download of CVSNT. These are the files that you might find missing:

    Once you have located the files, copy them to the %WINDOWS%\system32 folder.


Tuesday, 5 May 2009

Microsoft Outlook with Yahoo! Mail!!

You can use Outlook with many Yahoo! Mail e-mail accounts. However, free Web browser-based Yahoo! Mail accounts based in China, Taiwan, or the United States can only be used in Outlook if you have a paid subscription Yahoo! Mail account that includes POP3 access and forwarding.

You can receive your Yahoo! Mail e-mail messages by using Outlook from most places with an Internet connection. Yahoo! Mail provides you access to an authenticated SMTP server — allowing you to send e-mail messages using Outlook from your Yahoo! Mail account when you use another Internet service, such as at your office or when traveling.

Do one of the following:

ShowAdd your Yahoo! Mail e-mail account

  1. On the Tools menu, click E-mail Accounts.
  2. Click Add a new e-mail account, and then click Next.
  3. Click POP3, and then click Next.
  4. Under User Information, do the following:
    1. In the Your Name box, type your full name the way that you want it to appear to other people.
    2. In the E-mail Address box, type your Member ID (or username), followed by the @ symbol and domain name.
  5. Under Server Information, do the following:
    1. In the Incoming mail server (POP3) box, type the server name from the chart below that corresponds to your e-mail address.
    2. In the Outgoing mail server (SMTP) box, type the server name from the chart below that corresponds to your e-mail address.
  6. Under Logon Information, do the following:
    1. In the User Name box, type your Yahoo Member ID (or username). Do not include the @ symbol or domain name.
    2. In the Password box, type your password.
    3. Select the Remember password check box.

      Note You have the option to have Outlook remember your password by typing it in the Password box and selecting the Remember password check box. Having Outlook remember your password means that you won't have to type your password each time you access the account; however, it also means that the account is vulnerable to anyone who has access to your computer.

      Use strong passwords that combine uppercase and lowercase letters, numbers, and symbols. Weak passwords don't mix these elements. Strong password: Y6dh!et5. Weak password: House27. Passwords should be 8 or more characters in length. A pass phrase that uses 14 or more characters is better. For more information, see Help protect your personal information with strong passwords.

      It is critical that you remember your password. If you forget your password, Microsoft cannot retrieve it. Store the passwords that you write down in a secure place away from the information that they help protect.

  7. To verify that your account is working, click Test Account Settings. If there is missing or incorrect information, such as your password, you will be prompted to supply or correct it. Make sure your computer is connected to the Internet.
  8. Click More Settings.
  9. On the General tab, under Mail Account, type Yahoo! Mail.
  10. Click the Outgoing Server tab, and then select the My outgoing server (SMTP) requires authentication check box.
  11. Click Use same settings as my incoming mail server, and then click OK.
  12. Click Next, and then click Finish.

Notes

  • Do not select the Log on using Secure Password Authentication (SPA) check box.
  • Unless specified by Yahoo! Mail, all server and address entries are typed in lowercase letters.

ShowRemove your Yahoo! Mail e-mail account

  1. On the Tools menu, click E-mail Accounts.
  2. Click View or change existing e-mail accounts, and then click Next.
  3. Click the Yahoo! Mail e-mail account that you want to remove, and then click Remove.
  4. Click Finish.

Yahoo! Mail server information

E-mail address Incoming mail server (POP3) Outgoing mail server (SMTP)
MemberID@yahoo.com pop.mail.yahoo.com smtp.mail.yahoo.com
MemberID@yahoo.com.ar pop.mail.yahoo.com.ar smtp.mail.yahoo.com.ar
MemberID@yahoo.com.au pop.mail.yahoo.com.au smtp.mail.yahoo.com.au
MemberID@yahoo.com.br pop.mail.yahoo.com.br smtp.mail.yahoo.com.br
MemberID@yahoo.ca pop.mail.yahoo.ca smtp.mail.yahoo.ca
MemberID@yahoo.com.cn pop.mail.yahoo.com.cn smtp.mail.yahoo.com.cn
MemberID@yahoo.es pop.correo.yahoo.es smtp.correo.yahoo.es
MemberID@yahoo.de pop.mail.yahoo.de smtp.mail.yahoo.de
MemberID@yahoo.dk pop.mail.yahoo.com smtp.mail.yahoo.com
MemberID@yahoo.fr pop.mail.yahoo.fr smtp.mail.yahoo.fr
MemberID@yahoo.com.hk pop.mail.yahoo.com.hk smtp.mail.yahoo.com.hk
MemberID@yahoo.co.id pop.mail.yahoo.co.id smtp.mail.yahoo.co.id
MemberID@yahoo.ie pop.mail.yahoo.co.uk smtp.mail.yahoo.co.uk
MemberID@yahoo.co.in pop.mail.yahoo.co.in smtp.mail.yahoo.co.in
MemberID@yahoo.it pop.mail.yahoo.it smtp.mail.yahoo.it
MemberID@yahoo.co.kr pop.mail.yahoo.com smtp.mail.yahoo.com
MemberID@yahoo.com.mx pop.mail.yahoo.com smtp.mail.yahoo.com
MemberID@yahoo.com.my pop.mail.yahoo.com.my smtp.mail.yahoo.com.my
MemberID@yahoo.no pop.mail.yahoo.com smtp.mail.yahoo.com
MemberID@yahoo.co.nz pop.mail.yahoo.com.au smtp.mail.yahoo.com.au
MemberID@yahoo.com.ph pop.mail.yahoo.com.ph smtp.mail.yahoo.com.ph
MemberID@yahoo.pl pop.mail.yahoo.com smtp.mail.yahoo.com
MemberID@yahoo.se pop.mail.yahoo.com smtp.mail.yahoo.com
MemberID@yahoo.com.sg pop.mail.yahoo.com.sg smtp.mail.yahoo.com.sg
MemberID@yahoo.co.th pop.mail.yahoo.co.th smtp.mail.yahoo.co.th
MemberID@yahoo.com.tw pop.mail.yahoo.com.tw smtp.mail.yahoo.com.tw
MemberID@yahoo.co.uk pop.mail.yahoo.co.uk smtp.mail.yahoo.co.uk
MemberID@yahoo.com.vn pop.mail.yahoo.com.vn smtp.mail.yahoo.com.vn

Yahoo partner ISPs in the United States

E-mail address Incoming mail server (POP3) Outgoing mail server (SMTP)
MemberID@ameritech.net pop.ameritech.yahoo.com smtp.ameritech.yahoo.com
MemberID@flash.net pop.flash.yahoo.com smtp.flash.yahoo.com
MemberID@nvbell.net pop.nvbell.yahoo.com smtp.nvbell.yahoo.com
MemberID@pacbell.net pop.pacbell.yahoo.com smtp.pacbell.yahoo.com
MemberID@prodigy.net pop.prodigy.yahoo.com smtp.prodigy.yahoo.com
MemberID@sbcglobal.net pop.sbcglobal.yahoo.com smtp.sbcglobal.yahoo.com
MemberID@snet.net pop.snet.yahoo.com smtp.snet.yahoo.com
MemberID@swbell.net pop.swbell.yahoo.com smtp.swbell.yahoo.com
MemberID@verizon.net incoming.yahoo.verizon.net outgoing.yahoo.verizon.net
MemberID@wans.net pop.wans.yahoo.com smtp.wans.yahoo.com

Yahoo partner ISPs in the United Kingdom

E-mail address Incoming mail server (POP3) Outgoing mail server (SMTP)
MemberID@btinternet.com mail.btinternet.com mail.btinternet.com
MemberID@btopenworld.com mail.btinternet.com mail.btinternet.com

Yahoo partner ISPs in Canada

E-mail address Incoming mail server (POP3) Outgoing mail server (SMTP)
MemberID@rogers.com pop.broadband.rogers.com smtp.broadband.rogers.com
MemberID@nl.rogers.com pop.broadband.rogers.com smtp.broadband.rogers.com

Microsoft Outlook Set up !

This tutorial shows you how to set up Microsoft Outlook 2003® to work with your e-mail account. This tutorial focuses on setting up Microsoft Outlook 2003, but these settings are similar in other versions of Microsoft Outlook. You can set up previous versions of Microsoft Outlook by using the settings in this tutorial.

To Set Up Your E-mail Account in Microsoft Outlook

  1. In Microsoft Outlook, from the E-mail Accounts menu, select Tools.
  2. On the E-mail Accounts wizard window, select Add a new e-mail account, and then click Next.

  3. For your server type, select POP3 or IMAP, and then click Next.
  4. On the Internet E-mail Settings (POP3/IMAP) window, enter your information as follows:
  5. Your Name
    Your first and last name.
    E-mail Address
    Your email address.
    User Name
    Your email address, again.
    Password
    Your email account password.
    Incoming mail server (POP3)
    POP, Pop.secureserver.net or IMAP, imap.secureserver.net.
    Outgoing mail server (SMTP)
    Smtpout.secureserver.net

    Click More Settings.

    NOTE: "smtpout.secureserver.net" is an SMTP relay server. In order to use this server to send e-mails, you must first activate SMTP relay on your e-mail account. Log on to your Manage Email Accounts page to set up SMTP relay. If you do not have SMTP relay set up and your Internet Service Provider (ISP) allows it, you can use the outgoing mail server for your Internet Service Provider. Contact your Internet Service Provider to get this setting.

  1. On the Internet E-mail Settings window, go to the Outgoing Server tab.
  2. Select My outgoing server (SMTP) requires authentication.
  3. If you did not change the SMTP relay section, select Use same settings as my incoming mail server. If you changed the user name and password in the SMTP relay section of your Manage Email Accounts page, select Log on using and enter the user name and password. The following example assumes you did not change your SMTP relay section in your Manage Email Accounts page.
  4. Go to the Advanced tab, and then change the Outgoing server (SMTP) port to 80 or 3535.
  5. Click OK.
  6. Click Next.
  7. Click Finish.

Reference:-
http://products.secureserver.net/email/email_outlook.htm

Remote shutdown of Windows from Linux box

  • 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, then
go to start > settings > Windows Security and you will get the ctrl-alt-del option screen.

  • 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)


Reference:-
  1. Link"http://code.activestate.com/recipes/360649/"
  2. Poweroff
  • 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.