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:

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

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

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

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

With persistence, it will work!

No comments: