0

From computer A, I want to call a batch file on Computer B. normally, I use psexec to do this. However, in this case, the batch file on computer B is located on a mapped network drive on computer B called "J:"

Is there a way I can make a command like this work?

psexec \\computerB J:\MyBatchFile.bat

Right now, it comes back to me and complains that J: does not exist

Yusubov
  • 5,815
  • 9
  • 32
  • 69
user952342
  • 2,602
  • 7
  • 34
  • 54

3 Answers3

0

I would try using the UNC path that J: is mapped to. You might be able to use some net use trickery to make sure J: is available.

Nick
  • 4,302
  • 2
  • 24
  • 38
0

J doesn't exist for the user because drives are mapped when the user logs on interactively. No true logon to the system, no drive mapping.

As has been suggested, you can try the UNC path to J but that may not work. PowerShell remoting (alternative to using psexec) has a "one hop" limit - if you execute a command on your workstation to invoke a command on a remote system, then attempt to access a non-local resource from that remote system, you'll be refused.

Is there any way you can execute that BAT file from computer A instead?

alroc
  • 27,574
  • 6
  • 51
  • 97
0

Use -e to load the profile, then the mapped drive should be there.

psexec \remotemachine -u [domain\username] -p [password] -e j:\whatevercmmand.exe