The Notebook Review forums were hosted by TechTarget, who shut down them down on January 31, 2022. This static read-only archive was pulled by NBR forum users between January 20 and January 31, 2022, in an effort to make sure that the valuable technical information that had been posted on the forums is preserved. For current discussions, many NBR forum users moved over to NotebookTalk.net after the shutdown.
Problems? See this thread at archive.org.

    powershell & environment variables

    Discussion in 'Windows OS and Software' started by zakazak, Jan 26, 2010.

  1. zakazak

    zakazak www.whymacsucks.com

    Reputations:
    106
    Messages:
    1,299
    Likes Received:
    24
    Trophy Points:
    56
    Hello, i just tried around with wget.exe for windows.

    i set a new environment variable like this:

    name: wpath
    value: D:\Downloads\wget\

    So in cmd it works fine with:
    wget -P %wpath% [file-url]

    but in powershell it doesnt work. It creates a %wpath% folder in the current dir.

    Any ideas why?
    Thanks
     
  2. Pirx

    Pirx Notebook Virtuoso

    Reputations:
    3,001
    Messages:
    3,005
    Likes Received:
    416
    Trophy Points:
    151
    See help about_variables in PowerShell. Hint: Use the $-sign, as in $wpath... ;)
     
  3. zakazak

    zakazak www.whymacsucks.com

    Reputations:
    106
    Messages:
    1,299
    Likes Received:
    24
    Trophy Points:
    56
    this one didnt work either:

    wget -P $wpath [file-url]

     
  4. Christoph.krn

    Christoph.krn Notebook Evangelist

    Reputations:
    263
    Messages:
    423
    Likes Received:
    0
    Trophy Points:
    30
    Try using:
    Code:
    wget -P $env:wpath [file-url]
     
  5. zakazak

    zakazak www.whymacsucks.com

    Reputations:
    106
    Messages:
    1,299
    Likes Received:
    24
    Trophy Points:
    56
    oh perfect, worked :)

    thanks but is there any way to make it less "compliated/shorter" ?

    @edit:

    okay i found out, there is a way u can create a wget.ini and set the standart download direcoty.

    but i got another question then:

    i can use this command to put the outcome into a new file:

    ipconfig | out-file "ipconfig.txt"

    to set a path where to create it:

    ipconfig | out-file C:\ipconfig.txt

    now i want to set the path via a variable and it would be:

    ipconfig | out-file $env:wpath ipconfig.txt

    or smth similiar? but havent found which way it is yet :p

    thanks
     
  6. swarmer

    swarmer beep beep

    Reputations:
    2,071
    Messages:
    5,234
    Likes Received:
    0
    Trophy Points:
    205
    Can't you do:

    $env:wpath\ipconfig.txt

    or:

    ${env:wpath}\ipconfig.txt

    Am I missing something?