Eann
Eann

Reputation: 93

How to make the cmd line executable

Here's the situation, every time I need to do the step below after I boot my computer:

  1. Open the cmd(admin)

  2. copy this cmd into cmd:

    C:\Windows\system32\netsh int ipv4 set glob defaultcurhoplimit=65
    
  3. enter

For now, I hope to double click a file that can directly execute the command above without the step above.

Any method?

Upvotes: 3

Views: 14211

Answers (2)

Serge Ballesta
Serge Ballesta

Reputation: 148890

You need a .bat file to execute the command and a shortcut to have it executed as administrator.

Creating the .bat file is trivial: use you favorite text editor (or notepad), type the command, optionnaly add a line PAUSE if you want to see eventual messages and save it to disk with a .bat extension (say c:\...\sethoplimit.bat)

Creating the shortcut is not much harder: right click on desktop, Create new..., Shortcut, and just select the newly created file

The magic comes now: right click on the newly created shortcut and click Properties, in Shortcut tab, click the Advanced button and select Execute as admin.

That's all. Each time you double click on the shortcut, Windows will start a console with elevated priviledges, eventually open the User Account Control confirmation dialog, and execute the batch file as administrator.

Here I showed you how to create the shortcut directly on the Desktop, but the same process can be used for a shortcut anywhere on a disk folder.

Upvotes: 2

Andrii Litvinov
Andrii Litvinov

Reputation: 13182

You can save it to .bat or .cmd file and run it on double-click.

  1. Create a file with any name and extension .bat I.g. setLimit.bat. I assume you know how to create files.
  2. Open file from above step in file editor, i.g. notepad.exe. Copy and paste line C:\Windows\system32\netsh int ipv4 set glob defaultcurhoplimit=65 into the file and press Ctrl+S to safe it. I hope it makes sense otherwise ask.
  3. Double click on the file to execute the command.
  4. If you need to run it under elevated privilege (i.e. admin) right click on file and choose Run as administrator option in menu.

Upvotes: 5

Related Questions