System Level Command Prompt


  1. Posts : 2
    Windows 7 Home Premium 64-bit SP1
       #1

    System Level Command Prompt


    I am trying to make a System level command prompt show up in the Context (right click) menu.

    I have used the Ultimate Windows Context Menu Customizer to see if I can open up a System Command Prompt from the right-click menu. Here is my code that I used to make it show up in the context menu:
    runas /user:HP\Administrator "C:\Users\____\Downloads\PSTools\psexec -hsi cmd.exe && /L /k pushd %L

    If you notice, I use the Psexec tool to start the System Level command prompt. And the reason why I use the Administrator account is because the Psexec tool cannot work with out administrative privilages. And also to add a level of security to it so that only I can start this System CMD. The code sorta works; i.e. It shows up in the context menu. But it only works with folders. I want to see if anyone can edit my code so that it will work for files, such as a picture. To be more specific, I want to see if anyone can make code that will open CMD to the file Directory that the file I right-clicked is in. For example:

    Picture A is in Directory C:\Users\User\Pictures\ If I right-click Picture A, and press System command prompt, I want it to open with the directory C:\Users\User\Pictures\

    Can anyone Help me out? Thanks
    -Brand3n
      My Computer


  2. Posts : 1,872
    Windows 10 Pro x64, Windows 8.1 Pro x64, Windows 7 Ultimate x64 SP1,
       #2

    See if this tutorial will help

    Open Command Window Here as Administrator
      My Computer


  3. Posts : 450
    Windows 7
       #3

    Here is a DOS .bat file called filedir.bat that should work:


    set filedir=%~dp1
    set filedir="%filedir%"


    Whereby you have passed a fullpathname with double quotes around it for invocation:

    filedir.bat "C:\my\long\full\directory\path\image.jpg"

    the bat would return only the path portion (ending with a "\") up to image.jpg. In this case:

    C:\my\long\full\directory\path\


    Not sure how to wrap tall this up, but inside the .bat file you'd need to invoke whatever you are needing and passing %filedir%. Such as:

    nextbattorun.bat %filedir%

    So, your final .bat file would be something like:

    set filedir=%~dp1
    set filedir="%filedir%"
    nextbattorun.bat %filedir%

    The passed parameter to nextbattorun will have double-quotes around it to allow imbedded spaces in the path name nodes. I'm not exactly sure what nextbattorun.bat would do. Pass the %1 parameter to windows explorer's GUI executable???
      My Computer


  4. Posts : 2
    Windows 7 Home Premium 64-bit SP1
    Thread Starter
       #4

    Thanks pbcopter for showing me that tutorial. It allowes me to clean up my code a little bit. But I'm still having that problem where it won't let me open a System Command Prompt when I right click files. Below I have posted a picture of what it looks like when I try to right click files. The file I'm clicking on it called "Document A" located at C:\Users\____\Documents\Folder

    System Level Command Prompt-pic-1.png

    After I click that, it opens up to a Command prompt where you have to put in the password for the Built-in Administrator account. Which is what I want it to do. But after that it comes up with the Command Prompt box that says this:

    System Level Command Prompt-pic-2.png

    As you can see, it's running with System privilages, but it's the wrong directory. Is there any way to make it so that whatever file I select, it opens with that file's directory?

    And thank you to JimLewandowski for the suggestion but I'm trying to run this from the context menu and not a Batch file. Thank you anyway.
      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 11:03.
Find Us