Showing posts with label path. Show all posts
Showing posts with label path. Show all posts

March 14, 2022

Change default directory of Windows command prompt and Windows PowerShell

 Hi all,

Today I will explain the steps to change the default directory for Windows command prompt and Windows PowerShell.

The default directory for both the command prompt and PowerShell is the "system32" folder of the OS installed directory (By default: "C:\windows\system32").

Day in - Day out, we will open the terminals (command prompt / PowerShell) and navigate the source directory. It sometimes irritates and wastes lots of time.

I have come across this situation and want to avoid re-entry the change directory command.

Environment,

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


Change default directory of Windows Command Prompt

  1. Right-click on the taskbar pinned Command Prompt icon
  2. Right-click on the "Command Prompt" menu
  3. Select the "Properties" item
  4. Under the "Shortcut" tab, you will find the "Start in:" label
  5. In the respective text box, enter the path you want to navigate by default.
  6. For example, "C:\Projects".

Change default directory of Windows PowerShell

  1. Open the PowerShell with administrator privileges
  2. Create a profile by using the following steps
    1. New-item -type file -force $Profile
  3. This will create a file "Microsoft.PowerShell_profile.ps1" in the current user documents PowerShell folder.
    1. Syntax
        • C:\Users\<UserName>\Documents\WindowsPowerShell
      1. Example
          • C:\Users\PSR\Documents\WindowsPowerShell
      2. Edit file
          • notepad.exe $Profile
        1. Change the default directory
          1. Syntax
              • Set-Location <Directory Path>
            1. Example
                • Set-Location C:\Projects
                  • Clear-Host # To clear the PowerShell screen
              1. Save and close the file
              2. In the PowerShell window, enter the following command to change the profile
                  • . $Profile
                1. It immediately changes from the current directory to the updated default directory.
                2. Close the PowerShell and try to open the PowerShell again to see the change in the directory.
                Hope the above information is helpful to you reduce the change directories in day-to-day life.

                Send me your valuable feedback to psrdotcom@gmail.com.

                December 07, 2020

                C# get windows user app data folder path

                 Hi folks,

                Today I will explain to get the folder path of the windows user specific app data for storing any program (app) based information in C# (.NET Framework, .NET CORE, .NET 5)


                Source

                using System;

                using System.IO;

                namespace NETFrameworkConsoleApp1

                {

                    class Program

                    {

                        static void Main(string[] args)

                        {

                            string dir = Path.Combine(

                                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),

                                "FolderName"

                            );

                            Console.WriteLine("User Appdata Path: \n " + dir);

                            Console.ReadLine();

                        }

                    }

                }


                Hope this helps you to customize your requirement.

                References

                https://docs.microsoft.com/en-us/dotnet/api/system.environment?view=net-5.0

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


                C++ get windows user app data folder path

                 Hi folks,

                Today we will see how we can get the folder path of the windows user specific app data for storing any program (app) based information.


                Source

                #include <iostream>

                #include <tchar.h>

                #include <shlwapi.h>

                #pragma comment(lib,"shlwapi.lib")

                #include "shlobj.h"

                using namespace std;

                int main()

                {  

                    TCHAR szPath[MAX_PATH];

                    // Get path for each computer, non-user specific and non-roaming data.

                    if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, szPath)))

                    {

                        // Append product-specific path

                        PathAppend(szPath, _T("\\App Folder Path\\"));

                        wcout << "User AppData Roaming Folder Path: \n" << szPath << endl << endl;

                    }

                    

                    // Get path for each computer, non-user specific and non-roaming data.

                    if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL, 0, szPath)))

                    {

                        wcout << "System Program Files Folder Path: \n" << szPath << endl << endl;

                    }

                    cout << "==end==";

                }


                Hope this helps you to customize your requirement.

                References

                https://docs.microsoft.com/en-us/windows/win32/shell/csidl

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


                December 10, 2019

                Go language install and configuration in Windows and Visual Studio Code as IDE

                Hi folks,

                Today I am going to describe you the best way to install and configure the Go language.

                Download

                From the Go language from its official web page https://golang.org/dl/

                After installation, you would be able to program and run the code from any terminal.

                What else?

                Open your .go file in Visual Studio Code, it asks you something else. What was it?

                "The "go-outline" command is not available. Run "go get -v github.com/ramya-rao-a/go-outline" to install."

                What you need to do?

                First, in Visual Studio Code set the the following in "settings.json" file.

                "go.toolsGopath": "C:\\Go"

                Note: If you are getting the following error, then click on "Install All"
                The "go-outline" command is not available. Run "go get -v github.com/ramya-rao-a/go-outline" to install.

                • Get the location, where it is installing
                • Copy the bin and pkg folder contents to your Go installed folders.
                • Delete the folder which VS Code used to download the content.

                That's all.. you should be able to code in Visual Studio Code as well without having 2 different go installed folders.

                Happy Go coding!!

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

                January 24, 2019

                bash: C:/Program: No such file or directory error solution in git bash with windows directory path having spaces

                Hi friends,

                Today, I have come across a situation where I have to execute the gitbash on windows with linux commands.

                The escape character doesn't alone solve the problem

                Problem


                Setting up an alias for bash where the path includes space

                $ alias DOCKER_HOME=C:/Program Files/Docker/Docker

                Error

                bash: C:/Program: No such file or directory

                Solution

                $ alias DOCKER_HOME=C:/"Program\ Files"/Docker/Docker

                Hope my solution helps you in resolving the issue.

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

                December 30, 2016

                Windows file name too long to delete move copy rename due to destination path too long

                Hi friends,

                Problem

                When i am clearing my old windows folder from the OS installed drive, I had an issue of deleting the files and folder because the path name is too long.

                The error message is

                "Destination Path Too Long.

                The file name(s) would be too long for the destination folder. You can shorten file name and try again, or try a location that has a shorter path."

                Background

                Windows OS will allow the file path to be max 255 characters. If any file or folder path is beyond 255 characters, you will not be able to perform any file actions like delete / move / copy / rename.

                Solution


                1. Navigate to the folder in the windows explorer
                2. Type the following command in the address bar and hit enter key
                  • subst j:
                3. Open a new windows explorer window
                4. Now you will be able to see new drive with letter J:
                5. You will be able to delete the files/folders with in the drive
                6. To delete the other files, navigate to the parent folder and delete one after one or multiple folders path at a time.


                Please send your feedback or suggestions to psrdotcom@gmail.com

                January 19, 2015

                Windows: Copy all file names in a folder

                Hi friends,

                I’ve got a requirement like, I want to copy all the file names from a folder in Windows.

                After searching from Google, I’ve got one of the quick solution which is being described below

                Procedure:

                Navigate to the folder where you want to copy all the file name in “Windows Explorer”

                Select all the files (Key Board (KB) Shortcut: Ctrl + a)

                Press and hold the “Shift” key on your keyboard

                Right click your mouse by pointing to any one of the selected file

                From the context menu, select the option “Copy as path”

                Now, open “Notepad”

                Paste the content (KB Shortcut: Ctrl + v)

                Now, you will be able to see all the file name with full path

                You can remove the folder path, if you don’t want the full path

                Enjoy guys Smile

                Send your comments and feedback to psrdotcom@gmail.com

                Blogger Labels: Windows,Copy,folder,requirement,Google,solution,Procedure,Navigate,Explorer,Select,Board,Shortcut,Ctrl,Shift,From,context,menu,option,path,Notepad,Paste,Enjoy,Send,feedback

                December 12, 2013

                PhoneGap Installation and running Sample Application on Windows


                Pre-requisites


                Softwares

                1.       Node.js
                2.       Ant (Zip)
                3.       Java SDK 1.7
                4.       Android SDK
                5.       Eclipse (Zip)
                6.       Cordova (Zip)

                Setup Environment Variables

                1.       NODEJS_HOME
                2.       ANT_HOME
                3.       JAVA_HOME
                4.       ANDROID_SDK
                5.       CORDOVA_ANDROID

                PATH Environment Variable Update

                Add NODEJS\bin;ANT_HOME\bin;JAVA_HOME\bin;ANDROID_SDK\tools;ANDROID_SDK\platform-tools

                Install phonegap

                If you are behind a proxy please set the proxy to npm (Node.js) command
                Syntax:-
                (HTTP) C:\> npm config set proxy http://proxy.company.com:port
                (HTTPS) C:\> npm config set https-proxy http://proxy.company.com:port

                Run the install command

                C:\> npm install –g phonegap
                C:\> npm install –g cordova
                Note: If you get any ”shasum (Checksum)” error, then please
                i)                    clear the npm and npm-cache directories from %User%/AppData/Roaming folder
                ii)                  Install the latest npm version
                Currently it is 1.3.21
                npm install https://registry.npmjs.org/npm/-/npm-1.3.21.tgz
                npm install -g phonegap


                Create Project

                Syntax: phonegap create
                Ex: phonegap create FirstPhnGpPrj com.pg.firstphngpprj PhoneGapPrj1

                ·         Now it will create some folders and corresponding files (HTML, CSS, JS)
                ·         Change the directory to your project directory
                o   Ex:- C:\> cd FirstPhnGpPrj

                Add Platform

                Syntax: cordova platform add
                Ex:- C:\FirstPhnGpPrj> cordova platform add android

                Tip:
                If it’s not working then you need to install the cordova (npm install –g cordova)
                Copy the cordova-android\bin from your downloaded&extracted zip file to %User%\.cordova\bin

                Run Phonegap for Individual Platform

                Syntax: phonegap run
                Ex:- C:\FirstPhnGpPrj> phonegap run android

                1.       By now, you will be getting your Android project hierarchy in your project_folder\platforms\android\
                2.       Import the existing android code from your Eclipse
                3.       Create\manage AVD
                4.       Run the project

                Adding Plugins to your project

                Pre-requisites

                ·         Install Git
                Tip: If you are behind a proxy then please add it your configuration
                Syntax: git config –global http.proxy http://proxyusername:proxypassword@server.company:port
                Ex: git config –global http.proxy http://abc:123@xyz.com:8081

                ·         Add git\bin to your PATH environment variable
                ·         You need to download the git files from https://git-wip-us.apache.org. So make sure that the above specified URL is not blocked by your firewall
                ·         Navigate to your project directory in command prompt by changing the directory
                cd

                Install Plugin

                Syntax: phonegap local plugin add
                Ex:- phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
                Tip: If this doesn’t run then try with cordova
                Syntax: cordova plugin add

                Remove Plugin

                Syntax: phonegap local plugin remove
                Ex:- phonegap local plugin remove https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
                Tip: If this doesn’t run then try with cordova
                Syntax: cordova plugin remove

                Alternative

                You can install “plugman” to plug and play with plugins by following this link

                References


                Featured Post

                Java Introdcution

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