Tuesday, October 06, 2020

Creating Command Prompt aliases and shortcuts Using Windows DOSKEY.



The following describes the steps to run a batch script that creates aliases using DOSKEY when opening command prompt. The batch file also creates an alias command that can be used to create aliases during the command line session.

Steps

  1. Create a Batch file with the commands
  2. Create shortcut that will run cmd with the batch file as input to the /k switch

Create a Batch file with the commands

  • Open Notepad and copy the section between the markers and paste into notepad
    save the file to %USERPROFILE%\cmdrc.cmd
    ==== copy from @echo off to @echo on ====
    @echo off
    DOSKEY alias=if ".$*." == ".." ( DOSKEY /MACROS ) else ( DOSKEY $* )
    DOSKEY ls=DIR $* 
    DOSKEY cp=COPY $* 
    DOSKEY xcp=XCOPY $*
    DOSKEY mv=MOVE $* 
    DOSKEY clear=CLS
    DOSKEY h=DOSKEY /HISTORY
    DOSKEY history=DOSKEY /HISTORY
    ::compound commands
    set REPOS=%USERPROFILE%\Repos
    DOSKEY repos=cd /d %REPOS%$Tdir /a:d /b
    DOSKEY waffle=cd /d %REPOS%$Tdir /a:d /b$Tcd waffle$Tdir /a:d $Tgit branch
    DOSKEY bw=cd /d %REPOS%$Twaffle-build.cmd
    @echo on
    ==== copy from @echo off to @echo on ====
  • Customise your shortcuts
    • Place command separator as $T 
    • when you edit the cmdrc.cmd file run it again
      • %USERPROFILE%\cmdrc.cmd

Create a Shortcut to run the resource file

  • Open Windows Explorer and create a New Shortcut
  • Open the Shortcut Properties
  • Select the General Tab and Name the Shortcut e.g.
    • DosKey Alias - Command Prompt



  • Select the Shortcut Tab and set the Target
    • %windir%\system32\cmd.exe /k %USERPROFILE%\cmdrc.cmd


Tips on using the new alias batch file

Place command separator as $T in usual batch as an && or ||

This line "DOSKEY repos=cd /d %USERPROFILE%\repos$Tdir /a:d" in the batch below


In the command prompt window; the execution flow will result in the following when USERPROFILE is c:\users\myusername\repos
1. change to the device C:  
2. change to the directory to c:\users\myusername\repos
3. list directories only

Creating an alias 
while in the command prompt is opened using the Target as described above, you can create alias using the alias command.
alias lsb=DIR /b $*

Testing the new alias 
lsb c:\windows


Saturday, November 14, 2015

Windows 10 Upgrade cheat sheet


Decide if you want Windows 10 32-bt or 64-bit
64-Bit if you want to be able to nearly run ALL software available, both 32-bit and 64-bit software
32-Bit if you only want to be able to run 32-bit software
If you don't have an OS on the Device, You'll need another Device for the Installation Media Download
Use a 32GB Flashdrive 
 Follow the steps in the follow link: http://www.microsoft.com/en-gb/windows/windows-10-upgrade
Click Get Started
Download GWXWebWindows.exe to your Device
On your Device, click GWXWebWindows.exe
Follow this page: https://www.microsoft.com/en-gb/software-download/windows1
Click whichever installation you want on your Device
Download Tool Now (32-bit version)
downloads the file named: MediaCreationTool.exe
Download Tool Now (64-bit version)
downloads the file named: MediaCreationToolx64.exe
Run the Media Creation Tool for whichever version of Windows 10 you want to install on your target device
Select the appropriate Radio Button and Click Next

Sunday, October 12, 2014

ORACLE: Database Links

Creating a Database Link

create database link [LINK_NAME] connect to [USER_ID] identified by [PASSWORD] using '[TNS_NAME]';

example

RDB=((DESCRIPTION...)
create database link RDB_LINK connect to RDB identified by RDB_USER using 'RDB';

ORACLE: Generating CSV output

CSV output to file

set linesize 130
set pagesize 0
set echo off
set wrap off
set heading off

-- get databases users
-- output to file in the same directory as where you have opened SQL*Plus
spool database_users.csv
select u.user_id || ',' || u.surname || ',' || u.forenames
from user u,
where LOWER(u.user_id) like '%a%'
spool off

BASH - Archiving Directories

Archive Directories

#!/bin/bash
# Loop through all directories within the current directory
# tar and gzip all files into a single tarball file
for dir in *
do
    if [ -d "${dir}" ] then
        echo "archiving ${dir} with tar -zcvf"
        echo "tar -zcvf \"${dir}\".tar.gz \"${dir}\""
        dest=`echo ${dir} | tr -t '[ ]' '[_]'`
        echo "dest is now ${dest}"
        tar -zcvf "${dest}".tar.gz "${dir}"
        rm -rf "${dir}"
    fi
done

Perl RegEx: Updating files


Using the Perl Interpreter to update a single file

perl -p -i -e 's{^([^\b\w\t]*)(.*)(openApplication)([^>]*)(.*) Form Menu(.*)$}{\1\2\3\4}' $APACHE_DOCS/$APP_URI/index.html


Using xargs to pass command line parameters to perl

cd /usr/local/adobe/central/

egrep -ir csr00001 * | cut -d: -f1 | xargs perl -p -i -e 's/csr00001/$ENV{HOSTNAME##.*}/g'

Saturday, February 27, 2010

Some Crypto in Anger - using JCE and BouncyCastle JCE Provider


OutputStream out = new ObjectOutputStream(new FileOutputStream("encrypter.key"));
// Serialize the secret to a byte array
ByteArrayOutputStream bos = new ByteArrayOutputStream();

ObjectOutput objectOutput = new ObjectOutputStream(bos);
 objectOutput.writeObject(secret);

objectOutput.close();

// Get the bytes of the serialized object and use them as the inputstream

InputStream is = new ByteArrayInputStream(bos.toByteArray());
streamEncrypter.encrypt(is, out);

Thursday, January 17, 2008

Subversion in Anger

This is a very, and I mean very quick note...

When you want to create a subversion repository and if you want to add the "best practices"

C:\development\subversion\temp-repository>svnadmin create \development\svnrepos\evaluations
C:\development\subversion\temp-repository>svn import evaluations file:///c:/development/svnrepos/evaluations -m "Initial import"Adding evaluations\trunkAdding evaluations\trunk\sourceAdding evaluations\trunk\source\javaAdding evaluations\trunk\source\java\srcAdding evaluations\trunk\source\java\src\comAdding evaluations\trunk\source\java\src\com\activescriptAdding evaluations\trunk\source\java\src\com\activescript\guidAdding evaluations\trunk\source\java\src\com\activescript\guid\GUIDGenerator.javaAdding evaluations\trunk\source\java\src\com\activescript\guid\GUIDException.javaAdding evaluations\trunk\source\build.xmlAdding evaluations\trunk\docAdding evaluations\trunk\referenceAdding evaluations\branchesAdding evaluations\tags
Committed revision 1.

Friday, January 11, 2008

Using Shell file redirection to create a transcript of all content written out from a script

# #################################################
#
#Redirect to file while keep output writing to the console
# This could be used to create a transcript of your files. #
##################################################
start_transcript(){
declare -x OUTPUT_TRANSCRIPT=/tmp/$TRANSCRIPT_FILE
declare -x OUTPUT_PIPE=/tmp/$PIPE_FILE
if [ ! -e $OUTPUT_PIPE ]; then
mkfifo $OUTPUT_PIPE
fi
if [ -e $OUTPUT_TRANSCRIPT ]; then
rm -vf $OUTPUT_TRANSCRIPT
fi
exec 6>&1 7>&2
tee $OUTPUT_TRANSCRIPT < $OUTPUT_PIPE >&6 &
tpid=$!
exec > $OUTPUT_PIPE 2>&1
}
export -f start_transcript

end_transcript(){
echo "closing output pipe $OUTPUT_PIPE"
exec 1>&6 6>&- 2>&7 7>&-
wait $tpid
rm -vf $OUTPUT_PIPE
}
export -f end_transcript


# Using the transcript functions
declare -x TRANSCRIPT_FILE={$0##/*}.$$.transcript
declare -x PIPE_FILE=$TRANSCRIPT_FILE.pipe
start_transcript
echo "transcript started with - ${TRANSCRIPT_FILE} and pipe ${PIPE_FILE}"

#this is where all your main code will be

# at the end of the file
end_transcript #

Monday, October 15, 2007

JVM Memory Settings: Speed up your Eclipse and MyEclipse Startup

On Windows XP and probably other Windows OS versions; edit your eclipse.ini file which is located in the same directory as you eclipse.exe binary.

-vmargs-Xms256M-Xmx512M-XX:PermSize=128M-XX:MaxPermSize=256M