Showing posts with label Batch script. Show all posts
Showing posts with label Batch script. Show all posts

Friday, October 31, 2008

Remote Windows Service control

The command line way of controlling windows services is to use the net start and net stop commands. This will not work for remote servers though.

Instead we use the sc command. If I want to stop a service on GR0409A1, write:

sc \\gr0409a1 stop "Sonic CT_H1_ARN_StartGR0409A1 Service (AtlasProd)"


Also we can configure services with the sc command. To configure a service to autostart:

sc config "Sonic CT_H1_ACN_StartAtlasFileTransfer Service (LocalTest)" start= auto


This will work at least on XP.

Thursday, October 23, 2008

Rename files

I often have to rename files with the additional file extention .reject.
I basically just want to remove the .reject extention and keep the rest of the file.

This is the typical dirctory listing
C:\Apps>dir \\seit1705\D-Share\test\
 Volume in drive \\seit1705\D-Share is SEIT1705
 Volume Serial Number is 78E4-8FB3

 Directory of \\seit1705\D-Share\test

 2008-10-23  13:25  .
 2008-10-23  13:25  ..
 2007-10-03  16:45  1 144 E_DepSub_RME.xml.reject
 2007-10-03  16:45  1 144 E_DepSub_RME1.xml.reject
 2007-10-03  16:45  1 144 E_DepSub_RME2.xml.reject
 2007-10-03  16:45  1 144 E_DepSub_RME3.xml.reject
               4 File(s)          4 576 bytes
               2 Dir(s)  15 828 320 256 bytes free

You would think that this would do it:

ren \\seit1705\D-Share\test\*.reject *

But no... that command does NOTHING.

Ok, what about this:
ren \\seit1705\D-Share\test\*.reject *.xml


Nope, it produces this:
C:\Apps>dir \\seit1705\D-Share\test\
 Volume in drive \\seit1705\D-Share is SEIT1705
 Volume Serial Number is 78E4-8FB3

 Directory of \\seit1705\D-Share\test

2008-10-23  14:47              .
2008-10-23  14:47              ..
2007-10-03  16:45             1 144 E_DepSub_RME.xml.xml
2007-10-03  16:45             1 144 E_DepSub_RME1.xml.xml
2007-10-03  16:45             1 144 E_DepSub_RME2.xml.xml
2007-10-03  16:45             1 144 E_DepSub_RME3.xml.xml


Not what we want.

Solution:

ren \\seit1705\D-Share\test\*reject *xml


Amazingly works!