An error occurred while executing batch. Error message is: The directory name is invalid
I faced the error as mentioned in the title, while executing a query using linked server. The following steps where done to resolve the issue
1. checked the environment variables TEMP and TMP
2. from command prompt execute the following
echo %temp%
echo %tmp%
check if both are the same, and check if there is a directory with the name as you get from the environment variables. I found that there was folder name 7 and it was not available. I created manually that folder, the linked server executed successfully.