psexec script

Is it possible to use psexec script to check tell whether a server is still alive or not ?

Can we use psexec script to shutdown a NT 4.0 server ?

Tks
AXISHKAsked:
Who is Participating?
 
Brett DanneyConnect With a Mentor IT ArchitectCommented:
In all likelihood. But you can try \\machinename\admin$ this points to the windows folder. The admin$ share is what you need to be in place.
0
 
Will SzymkowskiConnect With a Mentor Senior Solution ArchitectCommented:
Instead of using psexec to accomplish this you might want to use psshutdown which should do the trick...

psshutdown - http://technet.microsoft.com/en-us/sysinternals/bb897541.aspx

If you want to know if a server is still alive in most cases a simple "ping" to the servers name or IP will tell you this. Sometimes ping can be false (when ping-able) if a server is unresponsive due to a stopped or halted service or core windows files are corrupt or damaged.

Will.
0
 
Brett DanneyConnect With a Mentor IT ArchitectCommented:
You can shutdow a remote machine from the command line using this:
shutdown -m \\machinename -r -f
-r = Restart.
-f = Close programs and force shutdown.
Out of interest -s will shut the machine down.

You could use a vb ping script to check if the servers are responding. The script below will ping a predefined list of servers and then write to a file the servers that did not respond. Save the following into a text file and save with .vbs

Option Explicit

Const ForReading = 1

Dim objFSO, objFile
Set objFSO = CreateObject("Scripting.FileSystemObject")

'List of hosts to ping - set path. Hosts listed in the file, one host per line.
Set objFile = objFSO.OpenTextFile("C:\path\hosts.txt", ForReading)

Dim fso, f1
Set fso = CreateObject("Scripting.FileSystemObject")

'List of hosts that did not respond. Set path.
Set f1 = fso.CreateTextFile("C:\path\noresponse.txt", True)



Dim Shell, strCommand, strHost, ReturnCode

'Host or IP to ping
Do Until objFile.AtEndOfStream
strHost = objFile.ReadLine

'Create shell object
Set Shell = wscript.createObject("wscript.shell")

'What to run in command line
strCommand = "ping -n 1 -w 300 " & strHost

'Run command and get return code
ReturnCode = Shell.Run(strCommand, 0, True)

'0 = pingable, 1 = no response
If ReturnCode <> 0 Then
f1.WriteLine ""& strHost &" is down"
End If
Loop

'Remove comment to have optional status message display when the script is complete.
'msgbox("Ping complete!")


Hope that helps.
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

 
AXISHKAuthor Commented:
Try the shutdown command but doesn't work..

10.0.20.26: The entered computer name is not valid or remote shutdown is not sup
ported on the target computer. Check the name and then try again or contact your
 system administrator.(53)


The workstation 10.0.20.26 can be pinged...

Any idea ?
0
 
Brett DanneyIT ArchitectCommented:
Apologies, should look like this:

shutdown /m \\machinename /r /f

You will need permissions to run this you can not run as a normal user. A quick way to establish a connection to a remote server from the command line as an administrator is to do this:

net use \\machinename\c$ /user:domain\username password
0
 
AXISHKAuthor Commented:
Result for PsShutdown command.

C:\Scripts>psshutdown \\10.0.20.26 -f -t 10

PsShutdown v2.52 - Shutdown, logoff and power manage local and remote systems
Copyright (C) 1999-2006 Mark Russinovich
Sysinternals - www.sysinternals.com

Couldn't access 10.0.20.26:
The network path was not found.

Make sure that the default admin$ share is enabled on 10.0.20.26.

If 10.0.20.26 is already performing a shutdown operation you must
abort it before issuing a different command.
0
 
Brett DanneyIT ArchitectCommented:
Is the default admin share enabled?
0
 
AXISHKAuthor Commented:
Try net use \\machinename\c$ from my DC, it said network path not found.

The workstation is rebuilt without change anything and already granted to the domain. THe domain administrator has been added in the local adminstrators of the workstation.

Anything I can check ?

Tks
0
 
Brett DanneyIT ArchitectCommented:
It would appear the admin shares are not present. I am sure you could correct this with a GPO or script.
0
 
AXISHKAuthor Commented:
if i can access c$ on remote pc, does it mean admin share is opened?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.