2

I'm working on rooting my LG V20 and the guide I'm using requires me to open a command-line window in the directory containing the root files. The issue I face is that Microsoft and their infinite wisdom decided to remove the option from the context menu. I want to know how I can make a batch script run this option when executed in a given folder or location (as in where the script is placed). I know I can run cmd with this code:

%SystemRoot%\System32\cmd.exe pause

Using this script however, does not appear to function the same way. I should be getting some other information in the command window according to the guide. If anyone would like to view the guide, it can be found here.

  • You can open the terminal THEN navigate to the desired folder. – user772515 Sep 22 '17 at 4:43
  • How? I only know how to navigate to a DOS executable. Do I just enter the path in the console? – Mr. Mendelli Sep 22 '17 at 4:45
  • 1
  • 1
    If you Shift + right click, 'Open Powershell' should be an option. Click that, then type cmd. This should run command prompt in that folder within the Powershell window. – George Tian Sep 22 '17 at 5:12
  • 1
    the cd command might help like cd \windows you might be able to use this in a shortcut or batch file start c:\windows\system32\cmd.exe /k "cd \windows" or just from a cmd prompt or a batch file do cd \windows – barlop Sep 22 '17 at 6:47
3

As I understand, you want a batch file that opens a CMD in the folder where it is located itself?

Add this lines in a file with file extension .bat.

pushd %~dp0
cmd.exe

After doubleclick you have a CMD window opened in the folder where the file is located.

| improve this answer | |
  • Excellent work! This functions precisley as I wanted. If I post this work-around on the tutorial thread, I'll be sure to credit everyone that helped make this possible. – Mr. Mendelli Sep 22 '17 at 8:30
1

Usually these batch files are written pretty poorly, and I make a habit of re-writing them for the hell of it whenever I root a phone.

That said you can open a CMD "Here" in windows 8.1/10 2012(R2)

To do that click "File" and click "Open Command Prompt" and select if you want a regular otr admin prompt (you can also right click on this and add it to the quick-access bar)

Opening CMD "Here" in Explorer - Example using Windows 2012R2, works in Windows 8.1 and forward.

Otherwise you can use this code in a batch file:

start /D "%~dp1" cmd 

This will allow you to drag and drop a file or folder onto the cmd file and it will start the cmd window in the directory of the file or folder.

If you want to make the CMD window start in the same directory as some script that you just want to add this line to, then you would use 0 instead of 1.

REM Some code in your current script

start /D "%~dp0" cmd 

REM some code that will execute after the new CMD window is popped up for you.
| improve this answer | |
  • 1
    Thank you, I will add this script method to my archives. – Mr. Mendelli Sep 27 '17 at 4:54
  • You're welcome, glad to help :) – Ben Personick Sep 28 '17 at 20:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.