netsvc.exe crossing domain question

OutHouse

Lifer
Jun 5, 2000
36,410
616
126
i use a log monitor program that was suggest to me from somebody on here years ago. great little program and best of all its free.

anyway i use it to monitor critical log files on various servers and if the log file hasnt been updated in x time it will run a bat file and send out a page to the oncall sys admin.

the problem is i have a new server with a buggy service on it that is pretty critical to a production process. the service will hang and the log file will page us and we will remote in and manually restart the service.

I have a couple of other servers where i use the netsvc.exe command to restart a service with a bat file then page us say so and so service has been restarted just to let us know and we dont have to get out of bed at 3am to restart a stupid buggy service. the to other servers are on the same domain as the host log monitor program...

the problem is that the new server is on a new 2003 domain that we are in the process of migrating to. the host server that runs the log monitor program is on a NT domain. when fire the bat file i get the following error in a cmd window.

Error code 5
Access denied.
Pausing 15 seconds

here is my little bat file, would anybody know of way to get this to work crossing domains? the service on the target machine has its logon set to local host.

c:\tools\SMTPMail -R %1 -M "CU Service on serverx has been restarted"

c:\netsvc.exe cuservice \\servername /stop
echo Pausing 15 seconds
sleep 15
c:\netsvc.exe cuservice \\servername /start
 

bsobel

Moderator Emeritus<br>Elite Member
Dec 9, 2001
13,346
0
0
"In order to use this utility, you must first have adequate permissions on the target computer. In most cases, Local Administrator equivalencies are required. "

Well, if the script is access controlled you could do the following (it's ugly as your domain admin pw is exposed...)

net use \\servername /user:Domainname\username password
c:\netsvc.exe cuservice \\servername /stop
echo Pausing 15 seconds
sleep 15
c:\netsvc.exe cuservice \\servername /start
net use * \\servername /delete