Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.


Go Back   Vista Forums > Misc Newsgroups > PowerShell

RB

Vista - Powershell as a better cmd.exe

Reply
 
12-11-2007   #1
dl__


 
 

Powershell as a better cmd.exe

I was looking at powershell as a replacement for cmd.exe but I ran into
problems right away. I'm wondering if powershell will not do these things or
it will do them as long as I use a different syntax.

First, I tried to run a batch file of DOS commands. I have several batch
files on the windows path that allow me to type a few letters and be
transported to a specific directory. So typically these batch files look
something like this:

d:
cd \mydir

These commands of course work exactly as expected when typed at the PS
prompt. As part of a batch file it also looks like they operate normally,
but are part of some separate process that terminates at the end of the batch
file leaving the current directory in PS unchanged.

If there a way to alter the batch file to make the commands stick to the
launching instance?

If not, is there a way to invoke the batch file so it applies to the
launching instance?

The second thing I tried was to launch a program that takes its input from a
file. I know about Invoke-Item so I tried

Invoke-Item myprog <myfile.txt

But I'm told that the redirection operator is not supported yet. Is it true
that this functionality is just not possible, or is it that I'm using the
wrong syntax for PS?

Thanks

My System SpecsSystem Spec
12-11-2007   #2
Shay Levi


 
 

Re: Powershell as a better cmd.exe

Hi dl__

PowerShell is certainly better than cmd.exe (I swear).

Your batch files run under a seperate process (cmd.exe) and wont affect PowerShell's
current directory.
I suggest to convert the files to ps1 scripts, soon enough you'll feel the
power of a PowerShell script.
Quote:

> Invoke-Item myprog <myfile.txt
As you already know, the redirection operator is not supported, so he above
syntax is not valid.


-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic


Quote:

> I was looking at powershell as a replacement for cmd.exe but I ran
> into problems right away. I'm wondering if powershell will not do
> these things or it will do them as long as I use a different syntax.
>
> First, I tried to run a batch file of DOS commands. I have several
> batch files on the windows path that allow me to type a few letters
> and be transported to a specific directory. So typically these batch
> files look something like this:
>
> d:
> cd \mydir
> These commands of course work exactly as expected when typed at the PS
> prompt. As part of a batch file it also looks like they operate
> normally, but are part of some separate process that terminates at the
> end of the batch file leaving the current directory in PS unchanged.
>
> If there a way to alter the batch file to make the commands stick to
> the launching instance?
>
> If not, is there a way to invoke the batch file so it applies to the
> launching instance?
>
> The second thing I tried was to launch a program that takes its input
> from a file. I know about Invoke-Item so I tried
>
> Invoke-Item myprog <myfile.txt
>
> But I'm told that the redirection operator is not supported yet. Is
> it true that this functionality is just not possible, or is it that
> I'm using the wrong syntax for PS?
>
> Thanks
>

My System SpecsSystem Spec
12-11-2007   #3
Jerry


 
 

Re: Powershell as a better cmd.exe

Go to jpsoft.com and check out their software: 4NT and Take Command

"dl__" <dl__@xxxxxx> wrote in message
news:7A8E78FB-73D2-4CF6-BA61-4F8EE8DD3049@xxxxxx
Quote:

>I was looking at powershell as a replacement for cmd.exe but I ran into
> problems right away. I'm wondering if powershell will not do these things
> or
> it will do them as long as I use a different syntax.
>
> First, I tried to run a batch file of DOS commands. I have several batch
> files on the windows path that allow me to type a few letters and be
> transported to a specific directory. So typically these batch files look
> something like this:
>
> d:
> cd \mydir
>
> These commands of course work exactly as expected when typed at the PS
> prompt. As part of a batch file it also looks like they operate normally,
> but are part of some separate process that terminates at the end of the
> batch
> file leaving the current directory in PS unchanged.
>
> If there a way to alter the batch file to make the commands stick to the
> launching instance?
>
> If not, is there a way to invoke the batch file so it applies to the
> launching instance?
>
> The second thing I tried was to launch a program that takes its input from
> a
> file. I know about Invoke-Item so I tried
>
> Invoke-Item myprog <myfile.txt
>
> But I'm told that the redirection operator is not supported yet. Is it
> true
> that this functionality is just not possible, or is it that I'm using the
> wrong syntax for PS?
>
> Thanks

My System SpecsSystem Spec
12-12-2007   #4
Jacob Saaby Nielsen


 
 

Re: Powershell as a better cmd.exe

Hey Jerry,

not to get religious (and then again...), but PoSH is both free and far more
versatile and powerful than
both Take Command and 4NT.

Best Regards,
Jacob Saaby Nielsen
mailto:jacob.saaby@xxxxxx
Quote:

> Go to jpsoft.com and check out their software: 4NT and Take Command

My System SpecsSystem Spec
Reply

RB


Thread Tools


Similar Threads for: Powershell as a better cmd.exe
Thread Forum
Installing PowerShell dependent features on W2K8 with PowerShell CTP PowerShell
when run powershell script as windows service ,powershell fail PowerShell
Powershell Plus - Free for non commercial Use and Powershell Analyzer1.0 released PowerShell
Automatic PowerShell Error Parsing in PowerShell Analyzer and PowerShellPlus PowerShell
PowerShell Leaders Join Forces and offer a pre-release version of PowerShell for 50% off the retail value PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd