Share via


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.

Comments

  • Anonymous
    July 27, 2014
    Log out from the server and RDP again then connect to SSMS you will not the issue again. It worked for me.

  • Anonymous
    March 04, 2015
    Thank you! Was struggling to run the queries and creating the folder mentioned in %TEMP% variable did the trick! Saved my day!

  • Anonymous
    October 19, 2016
    the %temp% solution fixed it for me too, thanks