Showing posts with label Shortcut. Show all posts
Showing posts with label Shortcut. Show all posts

May 23, 2023

Change default directory for Windows command prompt and Powershell when running with admin privileges

 Hi all,

It's been a while since I posted things.

Here is my previous post where the non-admin user changes the default directory for the command prompt and PowerShell.

https://psrdotcom.blogspot.com/2022/03/change-default-directory-of-windows.html

But in this post, I will be explaining about running the command prompt / powershell with admin rights and setting the default directory. Because, when you are running with admin privileges, it by default goes to the SYSTEM32 folder of Windows.

Environment

I use the command prompt and PowerShell, which are pinned to the taskbar of Windows.

Run the application with the admin rights

  • Right-click on the application icon -> click on Properties
  • Go to the "Compatibility" tab
  • Check "Run this program as administrator"

Run the shortcut with the admin rights

  • Right-click on the shortcut icon -> click on Properties
  • Go to the "Shortcut" tab
  • Click on the "Advanced" button
  • Check "Run this program as administrator"

Change the command prompt default directory

  • We need to have a .bat file with the following content
    • @echo off
    • cd <default_directory>
Now use the .bat file in the shortcut properties
  • Right-click on the shortcut icon -> click on Properties
  • Go to the "Shortcut" tab
  • In the "Target" field append the below text
    • /k "batfile_dirpath\batfile.bat"

Change the PowerShell default directory

  • Right-click on the shortcut icon -> click on Properties
  • Go to the "Shortcut" tab
  • In the "Target" field append the below context after powershell.exe
    • -NoExit -command "& {Set-Location <default_directory>}"
  • Click on "OK"

Hope, this helps you to reduce the frequent directory changes in the command prompt and PowerShell.

Feel free to provide your valuable feedback and comments to psrdotcom@gmail.com

May 13, 2013

Open command window shortcut with the current/present working directory/folder

In my previous post, I had explained about opening command prompt and auto-executing a command.
I was thinking it would be better, if we have a shortcut to open a command prompt in the present/current working directory/folder.

I found two options to do that.
GUI (Windows 7 and above):
  1. Hold “Shift” keyboard key and “Right Click” your mouse button
  2. You will find an option “Open Command Window Here”, click on it
  3. It will open a command window and path would be your current directory

Custom Shortcut:
  1. Right Click your mouse
  2. Choose “New”
  3. Select “Shortcut”
  4. Enter type the location of the item as “cmd” and click on “Next” button
  5. Enter type a name for this shortcut as your own custom name e.g. CurDirCmdWindow and click on “FInish” button
  6. It will create a shortcut with your own specified name
  7. If you run/double click the shortcut, it will open a command window with the path “C:\Windows\System32” i.e. the default command window directory
  8. Now, we have to change the default opening directory to the drive where this shortcut located
  9. I hope you are familiar with %CD% environment variable in windows, which stores the current working directory path. We are going to use this now.
  10. Select the shortcut and “Right Click” with mouse
  11. Select “Properties”
  12. Now shortcut properties windows gets opened
  13. In “Shortcut” tab, navigate to “Start in:” textbox
  14. Replace the existing “C:\Windows\system32” with %CD%
  15. Note: Don’t change the target textbox content
  16. Click on “Apply” and then on “OK” buttons
  17. If you run/double click the shortcut, it will open a command window with your current directory as path.

Please send your feedback and comments to psrdotcom@gmail.com

May 07, 2013

Create a command shortcut icon in windows to run a command like pinging Google website

Hi,

One of my friend asked me about how we can check whether ping/network is active or not?

He suggested that, if we have a shortcut command icon on desktop to create ping command then it would be easy for any naïve user to check whether ping/network is active or not?

 

Objective:

Creating Ping command shortcut with google.com

 

Procedure:

  1. Right click on the desktop
  2. Select “New” from the pop-up menu
  3. Choose “Shortcut” option
  4. Enter “cmd.exe /K ping google.com” as type of location of the item
  5. Click on “Next” button
  6. Enter “Ping Google” as name for the shortcut
  7. Click on “Finish” button
  8. Now you will be able to view a shortcut icon on desktop with name “Ping Google “ name
  9. When you run (Double click/Select and Enter) the “Ping Google”, you will be able to see that the command prompt displaying the content of running a ping to google.com

 

Send your feedback and comments to psrdotcom@gmail.com

December 24, 2011

Customize Command Prompt in Windows 7 with your own Icon, Starting Directory and more settings ...

Hi all,

Are you getting bored with the same command prompt with black colored background and other settings?

You can customize your own command prompt and you can start from the preferred location (Directory) path, choose your own icon and lot more.

Go ahead by following the below steps ..


Creating the shortcut icon on Destop
  1. Right click on the desktop, select "New" -> "shortcut"
  2. Browse for the command prompt executable file "cmd.exe"
  3. If you have installed your Operating System in C drive then the path might be similar to this
  4. C:\Windows\System32\cmd.exe
  5. Click on "Next"
  6. Type the name for this shortcut, something like "MyCmdPrompt"
  7. Click on "Finish"
  8. Now you can see your command prompt named of your own choice
  9. Now, you can change some properties of your command prompt

Changing the properties of the custom command prompt

  • Right click on the newly created shortcut from the Desktop
  • Select "Shortcut" tab and change the following settings
  1. Change the starting directory: Specify your own choice of directory path in the "Start in" box.
  2. Default Start in path: C:\Windows\System32
  3. Change the icon of your own choice: Click on "Change Icon" and Click on "Browse" button and Select the "C:\Windows\System32\imageres.dll" to list all the windows installed icons.
  4. Select an icon of your own choice and Click on "Ok"
  5. Run as Administrator by default: Click "Advanced" button, Select "Run as administrator" and Click "Ok"
  • Select "Options" tab and change the following settings
    1. Check "Quick Edit mode" to copy and paste easily
  • Select "Font" tab and change the following settings
    1. select your desired "Font" and "Size" settings
  • Select "Layout" tab and change the following settings
  1. select your desired "Window Size"
  2. Note: To see a bigger screen, increase the "Width and Height" attributes of the "Window Size"
  3. You can preview, your settings in the left side preview
  • Select "Colors" tab, You might be bored by seeing the same black and white combination.
  1. Choose your desired colors for Background, Foreground colors for both the "Screen" and "Pop-Up screen"
  • Click on "Apply" and then "Ok" to see your own command prompt.

Hope this post is useful to you customize your own Command Prompt in Windows 7.

For further queries, mail to psrdotcom@gmail.com

Featured Post

Java Introdcution

Please send your review and feedback to psrdotcom@gmail.com