Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PowerShell.exe and cmd.exe

824 views
Skip to first unread message

Larry__Weiss

unread,
Aug 4, 2009, 7:04:34 PM8/4/09
to
I'm thinking today about how cmd.exe and PowerShell.exe can work together.
I put this example together fairly quickly

powershell "&{if ('%USERNAME%' -eq 'LARRY') {echo 'Larry'} else {echo 'not
Larry'}}" >xo

as a starting point. At least PowerShell stays away from the redirection
characters in defining the comparison operators. That makes it a bit easier to
generate PowerShell from a batch script.

You can also execute the PowerShell logic from a PowerShell script file

powershell -File myscript.ps1 >xo

- Larry

Pegasus

unread,
Aug 5, 2009, 5:35:29 AM8/5/09
to

"Larry__Weiss" <l...@airmail.net> wrote in message
news:1fCdnUsiu_kZI-XX...@posted.internetamerica...

Pure batch files do not rely on redirection characters either for their
comparison operators:
EQU - equal
NEQ - not equal
LSS - less than
LEQ - less than or equal
GTR - greater than
GEQ - greater than or equal


Larry__Weiss

unread,
Aug 5, 2009, 10:48:33 AM8/5/09
to
Pegasus wrote:
> "Larry__Weiss" <l...@airmail.net> wrote in message
>> ... At least PowerShell stays away from the redirection
>> characters in defining the comparison operators. That makes it a bit
>> easier to generate PowerShell from a batch script.
>
> Pure batch files do not rely on redirection characters either for their
> comparison operators:
> EQU - equal
> NEQ - not equal
> LSS - less than
> LEQ - less than or equal
> GTR - greater than
> GEQ - greater than or equal
>

I was specifically contrasting embedding PowerShell scripts in batch files to
embedding, say, AWK scripts in batch files, where AWK uses the > < characters as
the comparison operators.

- Larry

0 new messages