Solved

Visual basic restart remote computer

Posted on 2004-09-03
5
1,060 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
squareUp  challenge 22 107
delphi parse string to params 3 82
Path to Python 9 48
Modify a small python script 19 54
A short article about a problem I had getting the GPS LocationListener working.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now