AngryHacker
AngryHacker

Reputation: 61636

Why do I get an error with sql cmdshell when it works in the actual shell?

I run the following:

EXEC XP_CMDSHELL 'fsutil fsinfo volumeinfo C:'

returns Error: The filename, directory name, or volume label syntax is incorrect. NULL NULL

However, hitting the D: drive works just fine. Also if I just run fsutil fsinfo volumeinfo C: from DOS prompt (e.g. regular command shell) - that works fine too.

What am I missing here?

Upvotes: 1

Views: 386

Answers (1)

I have no explanation as to why it doesn't work, but the following does work for me:

 EXEC master.dbo.xp_cmdshell 'fsutil fsinfo volumeinfo C:\' 

Note the inclusion of the backslash at the end of the query.

Upvotes: 1

Related Questions