Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Powershell script - Directory name as argument

Status
Not open for further replies.

meetme

Programmer
Oct 15, 2001
8
US
Hi PS Experts,
I am very new to PS.

I am trying to pass a directory name as parameter to a PS script and use a windows executable under that directory to do something. My power shell script is called like below

./script1.ps1 "C:\app\tin"

Inside the script (script1.ps1) I am calling the executable as below

param(
[string]$DIR
)

$DIR\temp\sc.exe

But when I execute, I am getting an error as below

Unexpected token '\temp\sc.exe' in expression or statement.

Why my PS script is not taking the directory name C:\app\tin? The sc.exe script is saved under C:\app\tin\temp\sc.exe

Thanks,
Sethu
 
$DIR\temp\sc.exe
You can see this from the console:
$dir=pwd

Should be $DIR + "\temp\sc.exe" or "$dir+\temp\sc.exe" or "$dir\temp\sc.exe"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top