Saturday, August 2, 2008

psexec remote batch file execution trailing slash problem solved

I've been working with a batch file that will execute an xcopy to transfer files to another server, then i execute a 'psexec' call to fire off a batch file located on the remote server.

Here are a list just some of the problems/solutions I ran accross:

Problem:
NT Scheduled Task Wouldn't complete -
Solution:
Created a domain user that had access to both machines to execute the batch file

Problem:
Working Directory was OFF when calling the remote batch file
Solution:
Specify -w or the absolute path on the remote server that this batch file is located in and should run/execute in.

Problem:
Error = [Microsoft][SQL Native Client]Unable to open BCP host data-file
Path was still not being rendered correct.
Solution:
Change the order of the -w argument to be after the remote computer but before the remote command
i.e. psexec \\xxx.xxx.xxxx -w "C:\mypath\pathtobatch" "c:\mypath\pathtobatch\batchfile.bat" (GOOD)
psexec \\xxx.xxx.xxxx "c:\mypath\pathtobatch\batchfile.bat" -w "C:\mypath\pathtobatch"(BAD)

Problem:
There seemed to be a path problem even after a working directory was specified
Solution:
Remove the trailing '\' Slash mark in the path
i.e. psexec \\xxx.xxx.xxxx -w "C:\mypath\pathtobatch" (good)
psexec \\xxx.xxx.xxxx -w "C:\mypath\pathtobatch\" (bad)

With persistence, it will work!

No comments: