I am working with a group of machines that are on the same network. They are all windows 2008 servers. I want to run a bat file on one machine by using psexec. But when I try, I am getting directory not valid. In fact no matter what directory/path I choose I get an directory not valid error. The firewall is off for both computers. Any suggestions?

  • what happens if you exec the file via wmi or wsman? – Jim B Jun 20 '12 at 17:18
  • the program I am using needs to run psesec. I would have to do alot of perl rewritting to change it now and prefer not to have do it if it is a simple change in security or registry setting. For example to get pslist to work all i had to do was add LocalAccountTolkenFilterPolicy = 1 in the Windows\Microsoft\Policies\System in the registry setting – Timothy McCormick Jun 20 '12 at 18:46
  • Can you post the PSexec task that you are trying to run now so we can attempt to see what's going on? Sometimes what you run into is the eula on the opposite end computer that stops the task from running. If this is the case just have -accepteula in your script – Dresca Jun 20 '12 at 21:10
  • the reason to try it with one of the "native" methods is to determine if you need to further reduce security (eg the reg setting above that allows users to get admin rights if they connect remotely) or if there is a problem with psexec. By default I don't believe psexec will work at all on vista and above without reducing security to winnt levels. Since powershell I haven't needed to use psexec at all so I haven't tried it, but it sounds like that's what you are facing. – Jim B Jun 21 '12 at 14:37

Psexec runs all pathing from the winnt\system32 as the working directory unless the -w switch is used. If I am having problems like this I start off doing this from a CMD window:

psexec \\machinename -u userID -p password cmd

This should open the remote command prompt for you. Then trying starting your scripts and figure out what working directory is needed. then you can use the -w switch to like so:

psexec \\machinename -u userID -p password -w WorkingDirectory BatchFileName

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.