System Level Command Prompt

Brand3n

New member
Local time
1:25 AM
Messages
2
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

Computer type
PC/Desktop
Computer Manufacturer/Model Number
HP
OS
Windows 7 Home Premium 64-bit SP1
CPU
AMD Athlon II X4 640
Antivirus
Microsoft Security Essentials and Spybot

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Built
OS
Windows 10 Pro x64, Windows 8.1 Pro x64, Windows 7 Ultimate x64 SP1,
CPU
INTEL i9-7920X LGA 2066
Motherboard
Gigabyte X299-WU8 F3
Memory
64 GB (4 X 16 GB) G-Skill V Series DDR4 3200 Quad Channel
Graphics Card(s)
EVGA GTX 1060 SC 3 GB
Sound Card
Realtek Onboard ALC1220
Monitor(s) Displays
2 x Samsung S27E310
Screen Resolution
1920x1080
Hard Drives
Samsung 2 x 970 EVO Plus 500 GB NVMe
1 x 6TB WD 6003FZBX SATA
1 x 6TB WD 60EFRX SATA
12 x 3TB WD 30EFRX SATA
PSU
Seasonic X-1050
Case
Thermaltake Armor+
Cooling
Corsair H80i V2 Liquid AOI Cooler
Keyboard
Logitech G510s
Mouse
Logitech MX Master 2S
Internet Speed
200 Mb/s
Antivirus
ESET NOD32 13.1
Browser
EDGE (Dev, Canary, Beta), Chrome
Other Info
ASUS RT-AC68U router
Malwarebytes 4.0.4
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

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom
OS
Windows 7
CPU
AMD Phenom II X2 (dual-core)
Motherboard
GA-MA785GM-US2H
Memory
4G
Graphics Card(s)
integrated ATI HD 4200
Sound Card
integrated
Monitor(s) Displays
Samsung 24"
Screen Resolution
1920x1080
Hard Drives
1 SSD - Samsung 840 - 500 GB - OS and DATA partitions
1 SSD - Intel 320 - 120 GB (used for backups) - Misc/BACKUP
1 SATA HD - WD, 500 GB - BACKUP
PSU
Ultra X4 500W
Case
Ultra X-blaster
Keyboard
Microsoft Digital Media Pro
Mouse
Logitech WIRED!
Internet Speed
15 Mbps FIOS
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

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:

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

Computer type
PC/Desktop
Computer Manufacturer/Model Number
HP
OS
Windows 7 Home Premium 64-bit SP1
CPU
AMD Athlon II X4 640
Antivirus
Microsoft Security Essentials and Spybot
Back
Top