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 - Call powershell script via Batch-File

Reply
 
07-02-2007   #1
kr1999@gmx.de


 
 

Call powershell script via Batch-File

Hi everyone,

i wrote a script to sign my powershell scripts. When I call the sign
script with a file to sign any file, the script works fine. But when I
create a batch file to call the powershell script with a file to sign,
I get the error message that no file name was given.

Batch-File:
..\SignFile.ps1 %1%

SignFile.ps1:
Param
(
[string] $File
)
$str = "Filename: " + $File
Write-Output $str
....

How have I to call the powershell script within my batch file to work
as I expect?

Thanks for the help,
Reiner


My System SpecsSystem Spec
07-02-2007   #2
Brandon Shell


 
 

Re: Call powershell script via Batch-File

Two things

1) you have to put powershell in front of the PS script name
powershell c:\pathtoscript\SingFile.ps1

2) you dont need trailing % on %1%

<kr1999@gmx.de> wrote in message
news:1183390091.989921.247580@w5g2000hsg.googlegroups.com...
> Hi everyone,
>
> i wrote a script to sign my powershell scripts. When I call the sign
> script with a file to sign any file, the script works fine. But when I
> create a batch file to call the powershell script with a file to sign,
> I get the error message that no file name was given.
>
> Batch-File:
> .\SignFile.ps1 %1%
>
> SignFile.ps1:
> Param
> (
> [string] $File
> )
> $str = "Filename: " + $File
> Write-Output $str
> ...
>
> How have I to call the powershell script within my batch file to work
> as I expect?
>
> Thanks for the help,
> Reiner
>


My System SpecsSystem Spec
07-02-2007   #3
kr1999@gmx.de


 
 

Re: Call powershell script via Batch-File

On Jul 2, 5:37 pm, "Brandon Shell" <tshell.m...@gmail.com> wrote:
> Two things
>
> 1) you have to put powershell in front of the PS script name
> powershell c:\pathtoscript\SingFile.ps1
>
> 2) you dont need trailing % on %1%
>
> <kr1...@gmx.de> wrote in message
>
> news:1183390091.989921.247580@w5g2000hsg.googlegroups.com...
>
> > Hi everyone,

>
> > i wrote a script to sign my powershell scripts. When I call the sign
> > script with a file to sign any file, the script works fine. But when I
> > create a batch file to call the powershell script with a file to sign,
> > I get the error message that no file name was given.

>
> > Batch-File:
> > .\SignFile.ps1 %1%

>
> > SignFile.ps1:
> > Param
> > (
> > [string] $File
> > )
> > $str = "Filename: " + $File
> > Write-Output $str
> > ...

>
> > How have I to call the powershell script within my batch file to work
> > as I expect?

>
> > Thanks for the help,
> > Reiner


Hello Brandon,

thanks for your help. It works as I expected.

Reiner

My System SpecsSystem Spec
Reply

RB


Thread Tools


Similar Threads for: Call powershell script via Batch-File
Thread Forum
How to call PowerShell script from C# PowerShell
Running batch file from Powershell script PowerShell
replicate a batch script to powershell PowerShell
function call from within powershell script PowerShell
Call Powershell script from ASP.NET page? 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