Solved

Visual basic restart remote computer

Posted on 2004-09-03
5
1,080 Views
Last Modified: 2009-10-30
Hello I am looking for a module that will allow me to restart remote computers.  Thanks
0
Comment
Question by:bluedragon99
5 Comments
 
LVL 36

Expert Comment

by:Zyloch
ID: 11976307
Hi

I don't know about remote computers, but you can force a system restart as long as your VB file is on their computer:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;168796

A problem in NT and 2000 and XP
http://support.microsoft.com/default.aspx?scid=kb;en-us;176695#appliesto

Regards,
Zyloch
0
 
LVL 5

Expert Comment

by:rsriprac
ID: 11977134
Here is a VB script to reboot remote computer:

http://www.freevbcode.com/ShowCode.Asp?ID=4889

-Ram
0
 
LVL 4

Expert Comment

by:Sicos
ID: 11977543
Just use tsshutdn ... it included in Windows 2000 and up... you can use it to restart remote servers..
As long you've got right for it on that server.

You also can call the program from VB or something like that.. just use WinEXec command for it.

Shut down a server in a controlled manner.

TSSHUTDN [wait_time] [/SERVER:servername] [/REBOOT] [/POWERDOWN]
         [/DELAY:logoffdelay] [/V]

  wait_time           Seconds to wait after user notification before
                      terminating all user sessions (default is 60).
  /SERVER:servername  The server to shut down (default is current).
  /REBOOT             Reboot the server after user sessions are terminated.
  /POWERDOWN          The server will prepare for powering off.
  /DELAY:logoffdelay  Seconds to wait after logging off all connected
                      sessions (default is 30).
  /V                  Display information about actions being performed.


Greetings Sicos..
0
 
LVL 3

Accepted Solution

by:
Validor earned 500 total points
ID: 11977860
I've written a VB module to do this for you.  This should reboot any remote (or the local) machine running an NT-based operating system if you have sufficient rights.  Example:


Private Sub Command1_Click()
    RestartRemoteComputer "myserver", roReboot
End Sub

'---------------------------

Public Declare Function InitiateSystemShutdown Lib "advapi32.dll" Alias "InitiateSystemShutdownA" (ByVal lpMachineName As String, ByVal lpMessage As String, ByVal dwTimeout As Long, ByVal bForceAppsClosed As Long, ByVal bRebootAfterShutdown As Long) As Long

Public Const roShutDown = 0
Public Const roReboot = 1

Public Sub RestartRemoteComputer(aComputerName As String, aRebootOption As Integer)
    InitiateSystemShutdown _
        aComputerName + Chr$(0), _
        "Shutting down...", _
        10, _
        1, _
        aRebootOption
End Sub
0
 
LVL 1

Author Comment

by:bluedragon99
ID: 11978089
Very nice clean working code that matches the description of the question.  Thanks!
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article will show, step by step, how to integrate R code into a R Sweave document
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question