windows xp - Why cmd.exe cannot access a lettter-mapped drive when it's "Run as..."

23
2014-04
  • Alois Mahdal

    Problem

    I have Windows XP SP3 here in VMWare, quite fresh installation, with just a bunch of applications (Browsers, Office) installed.

    When I:

    1. Log in as a local Administrator
    2. Using Explorer's GUI I connect a remote server as X:
    3. Launch "Command prompt" via Start menu link by either:
      a) launching the link manually
      b) right-clicking the link, choosing "Run as..." and filling credentials of the same user

    the former case works just fine, but in the latter one, cmd.exe cannot access X::

    C:\Documents and Settings\Administrator>net use
    New connections will be remembered.
    
    
    Status       Local     Remote                    Network
    
    -------------------------------------------------------------------------------
    Unavailable  X:        \\server\share\folder      Microsoft Windows Network
    The command completed successfully.
    
    C:\Documents and Settings\Administrator>x:
    The system cannot find the drive specified.
    
    C:\Documents and Settings\Administrator>dir x:\
    The system cannot find the path specified.
    
    C:\Documents and Settings\Administrator>
    

    Pre-analysis

    I have compared various properties I could find about the processes (I'm not sure that all of them are relevant): environment, open handles, open DLLs, "Security" tab in Process Explorer and all of them are the same.

    One thing I found is that when watching the attempt with Process Monitor, the succeeding one does four more steps:

    "Time of Day","Process Name","PID","Operation","Path","Result","Detail"
    "10:55:33.4784227 AM","cmd.exe","2792","RegOpenKey","HKCU","SUCCESS","Desired Access: Maximum Allowed"
    "10:55:33.4785212 AM","cmd.exe","2792","RegOpenKey","HKCU\Software\Policies\Microsoft\Control Panel\Desktop","NAME NOT FOUND","Desired Access: Read"
    "10:55:33.4785569 AM","cmd.exe","2792","RegOpenKey","HKCU\Control Panel\Desktop","SUCCESS","Desired Access: Read"
    "10:55:33.4786210 AM","cmd.exe","2792","RegQueryValue","HKCU\Control Panel\Desktop\MultiUILanguageId","NAME NOT FOUND","Length: 256"
    "10:55:33.4786650 AM","cmd.exe","2792","RegCloseKey","HKCU\Control Panel\Desktop","SUCCESS",""
    "10:55:33.4787131 AM","cmd.exe","2792","RegCloseKey","HKCU","SUCCESS",""
    "10:55:33.4912359 AM","cmd.exe","2792","CreateFile","X:","SUCCESS","Desired Access: Read Data/List Directory, Synchronize, Disposition: Open, Options: Directory, Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, AllocationSize: n/a, OpenResult: Opened"
    "10:55:33.4924104 AM","cmd.exe","2792","QueryNameInformationFile","X:","SUCCESS","Name: \server\share\folder"
    "10:55:33.4924860 AM","cmd.exe","2792","QueryInformationVolume","X:","SUCCESS","VolumeCreationTime: 9/6/2005 2:05:04 PM, VolumeSerialNumber: 109F-0912, SupportsObjects: True, VolumeLabel: DATA"
    "10:55:33.4932539 AM","cmd.exe","2792","CloseFile","X:","SUCCESS",""
    "10:55:33.4937810 AM","cmd.exe","2792","RegOpenKey","HKCU","SUCCESS","Desired Access: Maximum Allowed"
    "10:55:33.4939097 AM","cmd.exe","2792","RegOpenKey","HKCU\Software\Policies\Microsoft\Control Panel\Desktop","NAME NOT FOUND","Desired Access: Read"
    "10:55:33.4939451 AM","cmd.exe","2792","RegOpenKey","HKCU\Control Panel\Desktop","SUCCESS","Desired Access: Read"
    "10:55:33.4940098 AM","cmd.exe","2792","RegQueryValue","HKCU\Control Panel\Desktop\MultiUILanguageId","NAME NOT FOUND","Length: 256"
    "10:55:33.4940548 AM","cmd.exe","2792","RegCloseKey","HKCU\Control Panel\Desktop","SUCCESS",""
    "10:55:33.4941023 AM","cmd.exe","2792","RegCloseKey","HKCU","SUCCESS",""
    

    The steps CreateFile, Query* and, CloseFile are missing in the log of the failing one.

    Question

    What can cause such a discrepancy? Is this a bug?

  • Answers
  • JdeBP

    Starting with Windows XP, each LSA logon session (not related to Terminal Services sessions) has its own set of drive letter assignments. If you use Run As... – whether the account is same or different – the function still creates a separate logon session with the credentials given.

    More:

  • sinni800

    Because mapped drives are on a !PER USER! basis, the other user (which you do the RUN AS as) can not see it!

    To win, you need to try mapping a drive in a batch which is being run as the user first.


  • Related Question

    command line - Cannot open explorer windows with shortcut when cmd.exe is running
  • Questioner

    If cmd.exe is running (on Windows XP), and I try to open a explorer window by using the shortcut Windows+E, the window does not pop up. It pops up after the cmd.exe window is closed.

    This does not happen when I start the explorer from Start/Run or from another cmd.exe prompt.

    How can I open an explorer with the shortcut without closing cmd.exe?


  • Related Answers
  • admintech

    I just tried this and seems to work fine

    Went to start>Run> typed "cmd.exe">that was the main window, typed windows key and works fine