Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Physical and Network driver letters using WMIC command using SQL Server 2008

In my Windows Server 2008, I am having physical drives with letters 'C:', 'D:', 'E:', 'H:' and 'Z:' and DVD drive holds letter 'G:' and also having network drive with letter 'Y:'

If I execute the below query in command prompt

wmic LOGICALDISK LIST INSTANCE

I will get the result

enter image description here

But if run the below query in SQL Server 2008 in the same server. The network drive letter is missing in the output

EXEC master..xp_cmdshell 'wmic LOGICALDISK LIST INSTANCE'

The result is

enter image description here

like image 755
Venkatesh R Avatar asked Jul 21 '26 16:07

Venkatesh R


1 Answers

Mapped drives are mapped by user token. SQL Server almost never runs as a user, so has no access to user drive mappings.

Administrator have two user tokens. A limited user one and an administrator one. A mapped drive only applies to the user token that mapped it. Older windows won't let it be mapped by both tokens.

Mapped drives became obsolete around 1995. Yet bizarrely they live on. Use UNC naming \\servername\sharename\foldername\filename.ext.

like image 69
CatCat Avatar answered Jul 24 '26 11:07

CatCat