Showing posts with label Change. Show all posts
Showing posts with label Change. 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

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.

                March 17, 2020

                Connect to public hosted Ubuntu server MySQL Docker Image from local MySQL Workbench

                Hi folks,

                Today I am going to explain the procedure to test the public cloud hosted MySQL docker in Ubuntu Server to your local MySQL WorkBench.

                We configured a Ubuntu Server on public cloud and installed docker.
                Ping the public IP address to make sure, it is reachable to your pc/laptop.

                Configure System

                Install MySQL Docker Image

                # docker pull mysql/mysql-server:latest

                Check the images

                #docker images
                You should be able to view the downloaded mysql server image

                Start the MySQL Server

                # docker run --name=mysql1 -p 33061:3306 -d mysql/mysql-server
                -d : Run in daemon mode
                -p host_port:container_port
                --name: container name
                The mapped public ubuntu server port is 33061, which is mapped to the mysql server port 3306.

                Check the containers

                # docker ps
                You should be able to view your mysql docker containers with container id and ports information

                Get the MySQL root user password

                MySQL generates a one-time password for docker container and writes to the log.

                • To view the log, execute the following command

                # docker logs mysql1

                • To get the generate one-time password, filter the log with keyworkd "GENERATED"

                # docker logs mysql1 2>&1 | grep GENERATED

                • You should be able to get the line like below

                GENERATED ROOT PASSWORD: Axegh3kAJyDLaRuBemecis&EShOs

                • Copy the one-time password. In the next step, we will use this to login.

                Reset MySQL root user password


                • Connect to MySQL server

                # docker exec -it mysql1 -uroot -p

                • Paste the generated root password
                • Change the password

                mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourpwd';
                mysql> FLUSH PRIVILEGES;
                • Though you have the root user credentials, you won't be able to connect.
                Root cause: root user belongs to localhost, not for the public host usage
                Solution: create another user with all privileges
                mysql> CREATE USER 'username'@'%' IDENTIFIED BY 'youpwd';
                mysql> GRANT ALL PRIVILEGES on *.* TO USER 'username'@'%' WITH GRANT OPTION;
                mysql> FLUSH PRIVILEGES;

                • Exit the mysql

                mysql> exit;

                • Restart the docker

                # docker restart mysql1

                Connect from MySQL Workbench


                1. Open MySQL Workbench
                2. Click on add new connection icon
                3. Enter the "Connection name"
                4. Enter host name "public IP address" or "URL"
                5. Enter username as "dev" (Above created user)
                6. Click on Password "Store in vault" button and enter the "dev" user password
                7. Click on "Test Connection" button
                8. You should be able to view the "Successfully made the SQL Connection" pop-up


                Hope this tutorial helps you to get connected with your public hosted mysql docker instance to your local mysql workbench.

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

                August 10, 2018

                Microsoft Excel Copy row values to another sheet next available row when the value changes

                Hi friends,

                My friend had given me a problem in excel of copy row whenever the values changed to another sheet next available row.

                I have come-up with this following code

                Private Sub Worksheet_Change(ByVal Target As Range)
                    If Not Application.Intersect(Target, Target.ActiveSheet.Range("A1:D1")) Is Nothing Then
                        Application.EnableEvents = False
                        Application.ScreenUpdating = False
                        MsgBox ("Hi")
                        Call ValueChange
                        Application.EnableEvents = True
                    End If
                End Sub
                Sub ValueChange()
                        Dim lastrow As Long
                        
                        lastrow = Sheets("Sheet2").Range("A65536").End(xlUp).Row + 1
                        Sheets("Sheet2").Range("A" & lastrow & ": D" & lastrow).Value = Sheets("Sheet1").Range("A1:D1").Value

                End Sub

                Hope it will help you.

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

                February 22, 2017

                Tomcat issue "windows could not start apache tomcat on local computer" after java update issue with resolution

                Hi friends,

                Today I have faced an issue with Tomcat service starting. I would like to share with you the resolution as well. Please find the details below.

                Root cause

                Updated java version

                Resolution


                • Navigate to you apache installed folder
                • Go bin folder
                • Double click on "Tomcat(X)w.exe" where X the version of tomcat.
                • In my case it is "Tomcat8w.exe" because the version is 8
                • Select "Use Default". So that, it uses the JAVA_HOME version by default.
                • Click on OK
                • Start the Tomcat service and enjoy deploying


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

                January 20, 2017

                Change EOL (End Of Line) Character from Windows to Unix/Linux for all the files in current working directory

                Hi all,

                For a single file, you can do the change of EOL using notepad++.
                Reference: http://psrdotcom.blogspot.in/2017/01/change-eol-end-of-line-character-from.html

                But it would be difficult, if you want to do for multiple files in one go.

                I have found a solution to update EOL for all files in the current directory.

                Pre-requisite

                Make sure that, working directory contains only the files which you want to change EOL.

                Note: If not, copy the files to a new directory and change the EOL for all the files in that directory.

                Procedure

                1. Download dos2unix utility from sourceforge https://sourceforge.net/projects/dos2unix/
                2. Extract the zip file
                3. Tip: Make sure that the extracted path doesn't contain spaces.
                4. Keep the bin directory available in your PATH environment variables
                5. Download the customized batch file from GIST https://gist.github.com/psrdotcom/d73ff9590c3010253b5b2a886704b26b
                6. Extract if needed, and place the "dos2unixfolder.bat" in the same directory where the "dos2unix" is placed.
                7. Tip: If you place the batch file in the same folder of dos2unix.exe. You no need to add again the patch of batch file in environment PATH.
                8. Navigate to your folder, where you want all the files EOL to be changed
                9. Press "Right Click on Mouse" in empty area
                10. Select "Open Command Prompt Here"
                11. Type the batch file name "dos2unixfolder.bat"
                12. You will able to see the conversion process
                13. Once the conversion is completed, you can check the EOL coversion in notepad++.
                14. If you need to help in checking, refer to http://psrdotcom.blogspot.in/2017/01/change-eol-end-of-line-character-from.html


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

                Change EOL (End Of Line) Character from Windows to Unix/Linux using Notepad++

                Hi all,

                Today I will explain about updating/converting EOL for a single file from windows format to unix/linux format.

                1. In Windows, the EOL (End-Of-Line) character is \r\n (CR LF) (Carriage Return, Line Feed)
                2. In Unix/Linux, the EOL character is \n (LF) (Line Feed)

                Check for EOL

                If you open the file in notepad++, you will be able to see the EOL character by following below steps:


                • Type the content and hit enter button on keyboard
                • Choose menu "View -> Show Symbol"
                • Check the "Show End of Line" option

                • Now, you will be able to view "CR LF" special symbols in you file at every line end as show below

                Update EOL

                To convert the EOL from Windows (CR LF) to Unix (LF), do the following

                • Click on "Edit" menu
                • Choose "EOL Conversion"
                • Select "Unix(LF)"

                • Now, you can check the update EOL character in your file. Example conversion show below

                This type of conversion useful, when you are updating file in windows and using the same file in U/Linux environment.

                Batch File Update

                For all files in one folder, you can follow my blog.
                Reference: http://psrdotcom.blogspot.in/2017/01/change-eol-end-of-line-character-from_20.html

                Send your comments and feedback to psrdotcom@gmail.com

                August 22, 2015

                Ubuntu Windows dual boot order changes GRUB

                Hi friends,

                From long time, I was thinking of modifying my default boot option to Windows instead of Ubuntu. Finally today, I've done those changes in my laptop.

                My system has Windows 10 and Ubuntu 14.04 dualboot and Ubuntu OS is my default boot option with 10 seconds timeout.

                I thought of sharing the information with everyone.

                Please open the terminal and run the followin commands in sequence 
                1. sudo add-apt-repository ppa:danielrichter2007/grub-customizer
                2. sudo apt-get update
                3. sudo apt-get install grub-customizer
                By now, grub-customizer will be successfully installed in your PC.

                Please follow the below step to do the necessary changes in boot order

                • Open the grub-customizer
                 

                • Grub customizer lists the installed OS with versions
                 

                • Rename the OS entry by right clicking and selecting "Rename" option [Optional]
                 

                • Choose the default boot option by navigating to "General Settings"
                • Select options from "predefined" entry


                • Click on "Save" option to save all the changes.
                • You can revert the changes by clicking the "Revert" option, if you feel like going back to original/initial options

                Hope it would help you in changing the default boot order

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

                December 14, 2014

                Install and configure latest Oracle Java JDK 8 and 7 in Ubuntu

                Hi friends,

                Today, I'll try to explain the way how to install the latest Oracle Java JDK 8 and 7.

                Pre-requisites

                Ubuntu 12.02 or above

                Procedure

                We can install in two ways
                1. Using PPA
                2. Manual Installation

                PPA installation

                • Open terminal from "Applications" or press key combination "Ctrl+Alt+T"
                • Type the following commands in sequence
                  • $ sudo apt-add-repository ppa:webupd8team/java
                  • $ sudo apt-get update
                • To install latest JDK 8, type the following command
                  • $ sudo apt-get install oracle-java8-installer
                • To install latest JDK 7, type the following command
                  • $ sudo apt-get install oracle-java7-installer
                • Once the download complete, it will ask for agree for terms and conditions
                • Click on "OK" to complete the installation

                Manual Installation

                • Download the Oracle JDK from the following official link
                • Extract the downloaded zip (Example "jdk-1.8.0.25.tar.gz")
                • It will create a folder with name "jdk-1.8.0.25"
                • Create a folder "java-8-oracle" under "/usr/lib/jvm" folder
                  • $ sudo mkdir -p /usr/lib/jvm/java-8-oracle
                • Move the folder contents to /usr/lib/jvm/java-8-oracle
                  • $ mv jdk-1.8.0.25/* -rf /usr/lib/jvm/java-8-oracle/

                Configure the java executables

                Configuration can only be done if more than one JDK is installed.

                To configure java execute the following command

                $ sudo update-alternatives --config java

                Example output if Java 7 and Java 8 installed
                There are 2 choices for the alternative java (providing /usr/bin/java).

                  Selection    Path                                     Priority   Status
                ------------------------------------------------------------
                  0            /usr/lib/jvm/java-7-oracle/jre/bin/java   2         auto mode
                  1            /usr/lib/jvm/java-7-oracle/jre/bin/java   2         manual mode
                * 2            /usr/lib/jvm/java-8-oracle/jre/bin/java   1         manual mode

                Similar way you can do for javac, javaws and other executables

                Configure javac

                $ sudo update-alternatives --config javac

                Configure javaws

                $ sudo update-alternatives --config javaws

                Happy java coding guys :)

                References

                1. http://askubuntu.com/questions/121654/how-to-set-default-java-version
                2. http://askubuntu.com/questions/521145/how-to-install-oracle-java-on-ubuntu-14-04
                3. http://askubuntu.com/questions/56104/how-can-i-install-sun-oracles-proprietary-java-jdk-6-7-8-or-jre

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

                October 31, 2014

                Change IP Address and DNS from static to DHCP and vice versa in Windows Command Line Dynamically using Batch file script

                Hi friends,

                I was frequently changing my system network from static to dynamic.

                I was fed-up with the manual changes by entering the static IP address and changing it to dynamic.

                I though of creating a batch file, which requests user to select options and proceed further.

                 

                I found something on Internet, just modified it for my purpose and thought of sharing with you all.

                 

                • Check your network name
                  • cmd> netsh interface show interface
                • It will list all the network interfaces connected to your system
                  • Select the network which you want to change the settings
                • Modify the below code with appropriate network name, IP address, subnet, gateway and DNS server

                @echo off

                set NETWORK="Local Area Connection"
                set IP=10.9.40.95
                set SUBNET=255.255.255.0
                set GATEWAY=10.9.40.47
                set DNSSERVER=192.168.178.1

                echo Choose:
                echo [S] Set Static IP
                echo [D] Set DHCP
                echo.

                :choice
                SET /P C=[S,D]?
                for %%? in (S) do if /I "%C%"=="%%?" goto S
                for %%? in (D) do if /I "%C%"=="%%?" goto D
                goto choice

                :S
                @echo off
                echo "Setting Static IP Address, Subnet Mask and DNS Server"
                netsh interface ip set address %NETWORK% static %IP% %SUBNET% %GATEWAY% 1
                netsh interface ip set dnsservers %NETWORK% static %DNSSERVER% primary
                netsh interface ip show config
                pause
                goto end

                :D
                @echo off
                echo "Resetting IP Address, Subnet Mask and DNS server For DHCP"
                netsh interface ip set address name=%NETWORK% dhcp
                netsh interface ip set dns %NETWORK% dhcp
                ipconfig /renew

                echo "New IP Address, Subnet Mast and DNS Server for %computername%:"
                netsh interface ip show config
                pause
                goto end

                :end

                Now enjoy the feature of changing IP address with 3 clicks

                 

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

                Blogger Labels: Change,DHCP,vice,Windows,Command,Line,Batch,script,system,user,options,Internet,purpose,Check,interface,interfaces,Select,settings,Modify,gateway,server,NETWORK,Local,Area,Connection,SUBNET,DNSSERVER,Choose,Static,Mask,Mast,feedback,netsh,goto,config

                November 22, 2012

                Mount TrueCrypt Volume with Read and Write File Permission for Users and Groups

                Hi friends,

                I have been working on Ubuntu from a long time. Recently I am exploring on TrueCrypt and I faced the following issue. After searching lot of websites and forums, I made a solution which worked for me perfectly.

                Objective:
                TrueCrypt volume copied data should be available to all when its mounted.

                Usual Procedure:
                Mount the TrueCrypt volume in Ubuntu
                Copy some data to the volume
                Change file permissions to other users or groups
                Other users should be able to view the data from the volume when mounted

                Hiccup(Problem):
                After mounting the TrueCrypt Volume the directory permissions are changed and fixed to 700 (rwx --- ---). i.e. No access to groups and others.
                Changing the directory permissions and changing the ownership will not be applied.
                So, other groups and others cannot access the data.

                Solution:
                While mouting the TrueCrypt volume we need to specify the file system type and give permission to user[s] and/or group[s] with umask.

                Please find the syntax and example below

                Syntax:
                $sudo /usr/bin/truecrypt -t --filesystem={filesystem_type} --fs-options={rwx},uid={userid},gid={groupid},umask={ugorwx} {your_tc_volume} {mounting_folder}

                Example:
                $sudo /usr/bin/truecrypt -t --filesystem=vfat --fs-options=rw,uid=1000,gid=1000,umask=022 tc1.tc /mnt/folder1

                Thanks for visiting my blog.

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

                February 02, 2012

                ICICI Bank ATM Debit Card PIN Changing Procedure with Telephone Codes

                Hi friends,
                I have mistakenly typed the ATM pin 3 times at ATM. My ICICI card was blocked. This was the second time, it happened to me. I have generated the new PIN by calling customer care.

                Then I thought let me write the procedure to activate it through the telephone/mobile.

                Please follows these steps to activate your debit card with new ATM pin
                1. Turn Back your ICICI card, where your magnetic strip, cvv and grid exists. 
                2. On top of the card, you will find the major cities names along with customer care number. 
                3. Please call to any one of the customer care number (preferably your region/nearest phone number)
                4. 1111
                  • 1 -> Language Selection (English)
                  • 1 -> Existing Customer
                  • 1 -> Banking related queries
                  • A/c No. (or) Debit Card Number: Full Account Number (or) 16-digit debit card number
                  • 1 -> Generate PIN
                  • Card Expiry Date: Enter in the following format Ex: For Mar-2012, Please enter 0312
                5. Then the call will be connected to phone banking officer
                6. They will ask some security questions regarding your account details, which you have entered in the application form.
                7. Once the verification gets over, then the officer will transfer your call, So that you can generate your new PIN
                8. System will read the last 4 digits of your debit card
                9. You need to enter
                  • CVV -> Back of your card, 3-digit CVV will be displayed along with your last 4 digits of your card number
                  • New PIN -> Which you would like to change
                  • Re-enter PIN -> Same PIN which you have entered as New PIN

                Within no time, you can use debit card ATM PIN.

                For further assistance:
                http://www.icicibank.com/customer-care.html

                November 25, 2011

                Apply New, Change/Correct Your Voter Card Details Online in India

                Dear all,

                Choosing our leader is the gift which we are doing in India through elections. To do that, we need to have an voter card to utilize our vote.

                Andhra Pradesh Chief Electrol Officer has come with a website, where we can do the following things.

                1) Apply our voter cards online
                2) Corrections in the voter card details
                3) Know your status of the voter card application
                4) Transpose your location (Change in the location)
                4) Know your assembly constituency by giving your location
                5) Know your electoral rolls (Which poling booth you need to vote)
                and lot more.

                Please make use of this and vote for your leader.

                References:
                http://www.ceoandhra.nic.in/ceonew/home.aspx

                For any queries, mail to psrdotcom@gmail.com

                November 29, 2010

                File Magic Numbers in Header to differentiate between files

                Hi everyone,
                I just came to know about the file magic numbers
                http://en.wikipedia.org/wiki/Magic_number_%28programming%29

                Its good that, we can identify the file by converting the file to ASCII even someone changes the file extension manually.

                I personally tested this by creating one GIF file and saw the file ASCII values are starting with GIF89a.
                Later I manually changed the file extension to JPEG and I verified the ASCII values surprised that still the file ASCII values aren't changed. Its GIF89a.

                So, I understand one thing, that, if someone changes the file extension to some unknown type, we can easily find the original file extension by this method.

                To see the file ASCII values, use hexdump tool.
                http://www.richpasco.org/utilities/hexdump.html

                See the screeshots
                Demo_Image_GIF

                See the output ever after changing file extn

                Please send your comments and feedback to me

                August 05, 2008

                Changing MAC address of a system in Linux with root privileges

                Hi Friends,

                Have you ever tried to change the MAC address? It is so easy to do. Just follow the below steps.

                1. Login as root

                2. Write the MAC addresses of the system which u r going to change on a file or paper if you want the previous MAC addresses.

                3. Open terminal

                4. ifconfig eth0 down

                5. ifconfig eth0 hw ether XX:XX:XX:XX:XX:XX

                6. ifconfig up

                7. ifconfig

                Now your system MAC address will be changed to the specified MAC address. If any packet comes into the network to the specified MAC it will get confused where to go. If u specified the MAC address of the other system. i.e. if two system's MAC addresses are same.

                July 31, 2008

                Change Default Localhost File in Linux

                Hi friends,

                Whenever you type localhost or 127.0.0.1 in browser, you will be getting some default file.

                If you would like to change the default file and wants to put your own desired file then follow this procedure.

                1. Login into Linux as root
                2. Open the terminal
                3. cd etc/httpd/conf
                4. You can see the httpd.conf for configuration of httpd
                5. Place your .html file in /var/www/html
                6. Change the file name as index.html
                7. cd /etc --Change the directory to /etc folder
                8. service httpd start -- For starting the service
                9. service httpd restart -- To restart the service
                10. Now you open the browser
                11. In address bar of the browser type http://localhost/
                12. Now you will get your own html as default localhost
                For further queries/comments, please mail to psrdotcom@gmail.com

                Featured Post

                Java Introdcution

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