mgrenier
mgrenier

Reputation: 1447

Using PsExec in a Windows Service

I have created a Windows Service using C# which performs variance network maintenance tasks for me. One of the tasks is defraging machines remotely and for some of my older boxes I found the only way to do this was using psexec with defrag.exe. The code works fine when I simply run my C# code, however when I covert it into a Windows Service it does the defraging using the Win32_Volume table fine but it seems to get hung up when attempting to use PsExec to defrag the XP machines.

I guess my questions is, are there any known errors with using PsExec within a Windows Service? If so are there any suggestions for a different method I can use?

Thank you.

Upvotes: 1

Views: 1101

Answers (1)

Fergus Bown
Fergus Bown

Reputation: 1696

psexec issues a software licence agreement dialog the first time it is run as a given user, so that could be your problem if the service is running as some other user.

You can suppress this by adding the parameter

/accepteula

This could be your problem, though obviously I can't be sure!

Upvotes: 1

Related Questions