2

I wrote a batch file, which creates multiple folders und subfolders in the current directory. The group permission of one folder is also changed. This works on my local workstation with administrator privileges, but it doesn't work on the server, because I don't have the sufficient rights.

This batch should also be used by other non-administrator users, who don't have the right to change the permissions of folders and it's no option to give them this right.

After reading this comment, the solution seems to be obvious:

  1. Write a VBScript, which changes the permission of a given folder (folder-name is the argument)
  2. Run the VBScript as Windows Service (run as administrator)
  3. And change the batch so, that the Windows Service is called (passing the folder as argument)

My questions are: How can the batch send a command to the windows service? And in what way must the service be implemented, to receive this command and process it?

Christian
  • 121
  • 3

2 Answers2

0

You can check RunAsService which should be able to start one or more applications as a Windows Service.

You might want to check out this too.

Silviu
  • 637
  • 8
  • 15
  • Thanks. Yes, this is a part of the problem. My question is aiming more to the communication between client (batch) and service. How can the batch send a command to the windows service? And in what way must the service be implemented, to receive this command and process it? I'll edit the question. – Christian May 20 '12 at 12:00
0

The sc start command allows you to specify options which will be passed to the service's ServiceMain function.

I don't know offhand if any of the existing "run an application as a service" solutions will pass these arguments to the application, but it shouldn't be too hard to implement.

Make sure you validate the folder name carefully. You don't want someone being able to reset permissions on c:\folders\..\windows\system32, for example.

Harry Johnston
  • 6,005
  • 4
  • 35
  • 52