Crash course in PowerShell...

Last edited:
Yeah... I am still trying to decipher batch files... But I have found a new command that may make my life easier!!!

pushd... Tons of fun!
 
Powershell was originally intended to replace batch, but it never quite caught on.

don't you worry jcgriff lol that will come in time :) Assuming they don't completely revamp the Structure of Windows for any reason, not sure how Windows 8 is going to be, but they still haven't given up on Powershell, still comes preinstalled with Windows 8, as well as it's first appearance by default installation for Windows 7

pushd is amazing, it's known by various aliases in other languages as well. One of the many scripting languaes, and basically the only one that I really enjoy; Perl has this as well. Powershell and batch are also fun, but not as fun as it used to be, Perl and PHP are similar, but Perl has Threading abilities ! haha.
 
sets the directory...

open cmd and try it... popd then drops the pushed directory

great for batch files!!!!

cmd.png
 
What's the difference between PUSHD & CD commands then?

CD or CD /d (for different drive) would have the same net effect.
 
http://technet.microsoft.com/en-us/library/bb490978.aspx

Pushd


Stores the name of the current directory for use by the popd command before changing the current directory to the specified directory.

Syntax

pushd [Path]


Parameters

Path : Specifies the directory to which the current directory should be changed. This command supports relative paths.

/? : Displays help at the command prompt.


Remarks

Every time you use the pushd command, a single directory is stored for your use. However, you can store multiple directories by using the pushd command multiple times.

The directories are stored sequentially in a virtual stack. If you use the pushd command once, the directory in which you use the command is placed at the bottom of the stack. If you use the command again, the second directory is placed on top of the first one. The process repeats every time you use the pushd command.

You can use the popd command to change the current directory to the directory most recently stored by the pushd command. If you use the popd command, the directory on the top of the stack is removed from the stack as the current directory is changed to that directory. If you use the popd command again, the next directory on the stack is removed.


If command extensions are enabled, the pushd command accepts either a network path or a local drive letter and path.


If you specify a network path, the pushd command temporarily assigns the first unused drive letter (starting with Z:) to the specified network resource. The command then changes the current drive and directory to the specified directory on the newly assigned drive. If you use the popd command with command extensions enabled, the popd command removes the drive-letter assignation created by pushd.


Examples

You can use the pushd command and the popd command in a batch program to change the current directory from the one in which the batch program was run and then change it back. The following sample batch program shows how to do this:
@echo off
rem This batch file deletes all .txt files in a specified directory
pushd %1
del *.txt
popd
cls
echo All text files deleted in the %1 directory
 
Oh.... PUSHD stores the current DIR name for use by POPD command later.

Never knew that!
 

Has Sysnative Forums helped you? Please consider donating to help us support the site!

Back
Top