Problem open command Window(administrator)


  1. Posts : 32
    win7
       #1

    Problem open command Window(administrator)


    I'm trying to create some auto setup procedures but can not setup
    a CMD administrator command ( non administrator seems to work)



    registry tweak
    Code:
    ;  //run  administrator command from explorer 
    [HKEY_CLASSES_ROOT\Directory\shell\runas]
    @="Open Command Window Here (Administrator)"
    [HKEY_CLASSES_ROOT\Directory\shell\runas\command]
    @="cmd.exe /s /k pushd \"%V\""
    all seems to work perfectly on a local device
    but as I'm using a networked device (win7/64 fresh install -stable)
    the command prompt never apears (immedialty stops)

    both on mapped device net user //server/share x: /persist:yes
    and direct //server/share (workgroup//homegroup)

    any tips to further debug the problem /maybe a solution ???
      My Computer


  2. Posts : 1,020
    Windows 7 Ultimate 64 bit
       #2

    Hi dreuzel,

    This reg entry appears to create a right click option called "Open Command Window Here (Administrator)", which in turn opens a CMD prompt with admin elevation. You are saying that mapped drives don't open but local drives do, this is correct so far yeah?

    Take a look for any other entries in the registry that might effect the results. The places to check are:
    Computer\HKEY_Classes_root\*\shell\runas
    Computer\HKEY_Classes_root\Directory\shell\runas

    Meanwhile I'll test this too and let you know what I find.
    Attached Thumbnails Attached Thumbnails Problem open command Window(administrator)-cmd-registry-entries.png  
      My Computer


  3. Posts : 1,020
    Windows 7 Ultimate 64 bit
       #3

    Well I did some testing and found that I would receive the error "The system cannot find the drive specified." when I used the "Open Command Window Here (Administrator)" right click option on a networked mapped-drive shorcut.

    However there is a workaround - Don't use the mapped drive shortcut, use a UNC shortcut.

    e.g.
    \\networkedPC\myshare mapped as Z:\myshare
    If you right click on the shortcut Z:\myshare it fails with "The system cannot find the drive specified" error opening in your CMD window.
    If you rightclick on the shortcut \\networkedPC\myshare a temporary drive letter is allocated and it works.

    Hope this helps.
      My Computer


  4. Posts : 32
    win7
    Thread Starter
       #4

    exactly my point
    Now using Dos commands I often get problems they can not handle the UNC
    this is long term project of MS to get that in order .......
    spec's so we are in a locked up situation
    require UNC to work all over .....

    is there a way to add a mapped device ... (adding something before the
    mapped command @="cmd.exe /s /k pushd \"%V\""



    are there alternatives as %cd%
    what is %v in this case is this explained somewhere
      My Computer


  5. Posts : 1,020
    Windows 7 Ultimate 64 bit
       #5

    dreuzel said:
    exactly my point
    Now using Dos commands I often get problems they can not handle the UNC
    this is long term project of MS to get that in order .......
    spec's so we are in a locked up situation
    require UNC to work all over .....
    Sorry I was away on a job last night... back now to help.

    I'm not understanding a key piece of the puzzle here.
    1. What are you creating auto setup procedures for (is it software, installation, policy roll outs, etc)? I'm just trying to understand why the right click to admin-cmd is needed? If there is a different way to get the same results, understanding the project will help me help you.
    2. Is this to go into a batch or vbs script?
    3. The workaround is not good because UNC paths fail for another part of your project is this correct?


    dreuzel said:
    is there a way to add a mapped device ... (adding something before the
    mapped command @="cmd.exe /s /k pushd \"%V\""
    In batch-file world yes; but not so with our mapped drives (and I have no idea why)
    you can normally link to CMD lines together with the && command; but I tried for a few minutes and failed with our mapped drives.
    I also looked at finding the current path with %~dp0
    Code:
    set 	curpath=%~dp0
    pushd 	%curpath%
    but I couldn't get it to work from a single command line (i.e. && fails on this command because the variable needs to be found before it can be pushed). I will try again this evening when I have more time. I'll also look at 'calling' a batch file where we have more options and any other ideas that spring to mind (currently it's 11 am for me).

    dreuzel said:
    are there alternatives as %cd%
    what is %v in this case is this explained somewhere
    @="cmd.exe /s /k pushd \"%V\"
    The V% is the variable, in your example it is the directory that CMD is called to.

    Yep there's plenty of alternatives depending on what you want to do.
    For example if I was to.....
    Code:
    net use X: \\media\PICTURES
    X:
    I don't need to cd to get to X, just 'X:' on it's own suffices. But I can't do this in one line 'net use X: \\media\PICTURES && X:' because the drive needs to be mapped first before it can be found.

    You could use ~dp0 in place of %cd% for some instances.
    for an example paste these into a bat or a command window
    Code:
    echo this is %%cd%%  %cd%
    echo this is %%~dp0 %~dp0
    Lastly, for your scenario, is a shortcut that opens a CMD windows in a pre-specified mapped target an option?
      My Computer


  6. Posts : 1,020
    Windows 7 Ultimate 64 bit
       #6

    A follow-up.

    It doesn't work for me outside of the workaround I provided earlier. Hmm strange stuff.

    Let me know the answers to my questions above and we'll think of a route forward.
      My Computer


  7. Posts : 1
    win7 ulti x64
       #7

    fix


    i've been looking for how to do this in win7 for a while. it was SO much more simple in XP. your solution was close and got me started. :)

    here is a fix that worked for me:

    [HKEY_CLASSES_ROOT\Directory\shell\runas\command]
    @="cmd.exe /k \"pushd %L && title Command Prompt\""
      My Computer


  8. Posts : 1,020
    Windows 7 Ultimate 64 bit
       #8

    mastapat11 said:
    i've been looking for how to do this in win7 for a while. it was SO much more simple in XP. your solution was close and got me started. :)

    here is a fix that worked for me:

    [HKEY_CLASSES_ROOT\Directory\shell\runas\command]
    @="cmd.exe /k \"pushd %L && title Command Prompt\""
    Thanks Mastapat11 for posting that here. I've seen your solution on a number of other threads but I totally couldn't remember "this" thread to find it. It's good of you to leave that here for other readers (and of course triggering this to appear in my active threads once more. Stick around we can do with a fee more script writers ever now and then.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 17:03.
Find Us