Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: System Level Command Prompt

28 Feb 2013   #1

Windows 7 Home Premium 64-bit SP1
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

My System SpecsSystem Spec
28 Feb 2013   #2

Windows 7 Ultimate x64 SP1, Windows 8.1 Pro x64, Windows 10 Pro x64

See if this tutorial will help

Open Command Window Here as Administrator
My System SpecsSystem Spec
28 Feb 2013   #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:


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 System SpecsSystem Spec

28 Feb 2013   #4

Windows 7 Home Premium 64-bit SP1

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 System SpecsSystem Spec

 System Level Command Prompt

Thread Tools

Similar help and support threads
Thread Forum
Command Prompt of the DVD and editing the system registry
Hi If I perform the boot from the DVD of Windows 7 Ultimate SP1 64 bit and then I open the Command Prompt, I can run a bat file containing some reg commands to edit the system registry of Windows 7 SP1? If not, how do I edit the system registry from the Windows 7 DVD? Thanks Bye
General Discussion
How do I change system attribute for all folders using command prompt?
Let me share the background quickly. I work at a school as Computer Applications Technology teacher. The students bring homework to school on their flashdrives, and though we have good antivirus software at school, the viruses on their home PC's will often do considerable damage to the data on...
Performance & Maintenance
Can't type in Command Prompt in System Recovery
So, my original issue was that after installing an ubuntu partition on my computer, windows 7 would not go to sleep. After research I presumed this was caused by GRUB being installed in the windows MBR. I then made a system repair disk to run the fix boot and fix mbr commands. However, when I boot...
General Discussion
How would I run system restore from command prompt? Can not boot...
Backup and Restore
System protection enabled by command prompt?
Okies everyone who is willing to help....i have a huge problem. I installed windows 7 the other night for a friend. I had this thing working perfectly fine. So i ran into an issue after they restarted the pc for a windows update. Whenever i boot i see the black screen with Windows...
BSOD Help and Support

Our Sites

Site Links

About Us

Find 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 09:29.
Twitter Facebook Google+