locked
A change from url in my script. RRS feed

  • Question

  • I need to make a certain script for my internship installing programs through a script.

    The problem is now that the URL from the Citrixreceiver.exe changes making my script not useable.

    Anyone that can help me?

     function areyousure {$areyousure = read-host "Are you sure you want to exit? (y/n)"  
               if ($areyousure -eq "y"){exit}  
               if ($areyousure -eq "n"){mainmenu}  
               else {write-host -foregroundcolor red "Invalid Selection"   
                     areyousure  
                    }  
                         }    
     function mainmenu{  
     cls  
     echo "---------------------------------------------------------"  
     echo ""  
     echo ""  
     echo "  1. Get CitrixReceiver.exe"
     echo "  2. Start Displaylink.exe"  
     echo "  3. Get Ccleaner.exe" 
     echo "  4. Calculator"
     echo "  5. Exit"  
     echo ""  
     echo ""  
     echo "---------------------------------------------------------"  
     $answer = read-host "Please Make a Selection"  
     if ($answer -eq 1){wget https://downloads.citrix.com/13503/CitrixReceiver.exe?__gda__=1509025484_a86ecd982eb8f7ba4632af5f12698713 -OutFile C:\Users\User\Test\Citrixreceier.exe}  
     if ($answer -eq 2){start E:\DisplayLink.exe}
     if ($answer -eq 3){wget http://download.piriform.com/ccsetup536.exe -OutFile C:\Users\User\Test\Ccleaner.exe}
     if ($answer -eq 4){calc}  
     if ($answer -eq 5){areyousure}  
                    }  


    Thursday, October 26, 2017 1:20 PM

Answers

  • This is the correct way to download a file:

    $url = 'https://downloadplugins.citrix.com/Windows/CitrixReceiver.exe'
    $saveTo = "$pwd\CitrixReceiver.exe"
    $wc = [System.Net.WebClient]::new()
    $wc.DownloadFile($url,$targetPath)
    


    \_(ツ)_/

    • Marked as answer by Byaku Friday, October 27, 2017 7:49 AM
    Thursday, October 26, 2017 2:14 PM

All replies

  • What are you trying to say: that this link that you have right now, that it is not working?

    I have just tested it and it works just fine.

    Was able to download Citrix Receiver app

    What error message are you getting? Please share

    And for the future, please use the code block, it would be easier for everyone


    Please click on Propose As Answer or to mark this post as and helpful for other people. This posting is provided AS-IS with no warranties, and confers no rights.

    Thursday, October 26, 2017 1:38 PM
  • I just remade the link for the download before i posted this that is kinda my bad.

    But when some time passed (couple of hours) i get the error they can't find the URL. "error from the line that doesn't work"

    Also my bad around the code block. New on this forum and also new around scripting hahaha. 

    But this would be the error i would get this is a replica from ccleaner but i removed 1 c.

    (it's dutch sorry about that!)

    wget : De externe server heeft een fout geretourneerd: (404) Niet gevonden.
    At C:\Users\User\Documents\Test.ps1:25 char:21
    + ... swer -eq 3){wget http://download.piriform.com/csetup536.exe -OutFile  ...
    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest 
       ) [Invoke-WebRequest], WebException
        + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands 
       .InvokeWebRequestCommand


    Thursday, October 26, 2017 1:50 PM
  • Since the download path is constantly changing, it would be hard to automate.

    Are you able to re-configure the script and to put this .exe file to some kind of repository, e.g. network share, from where you would be able to connect and copy the installation package?

    This would make your life much easier.


    Please click on Propose As Answer or to mark this post as and helpful for other people. This posting is provided AS-IS with no warranties, and confers no rights.

    Thursday, October 26, 2017 1:56 PM
  • Alright i will have a chat with my supervisor around this.

    If anyone does have a solution i will keep my eye out on this forum :).

    Atleast thanks for your response.
    Thursday, October 26, 2017 2:03 PM
  • $link = 'https://downloads.citrix.com/13503/CitrixReceiver.exe?__gda__=1509025484_a86ecd982eb8f7ba4632af5f12698713'
    $answer = read-host 'Please Make a Selection'
    switch ($answer){
    	1 { Invoke-WebRequest $link -OutFile C:\Users\User\Test\Citrixreceier.exe }
    	2 { Start-Process E:\DisplayLink.exe }
    	3 { Invoke-WebRequest http://download.piriform.com/ccsetup536.exe -OutFile C:\Users\User\Test\Ccleaner.exe }
    	4 { calc }
    	5 { areyousure }
    }
    Doesn't this get the latest link: Start-Process E:\DisplayLink.exe

    \_(ツ)_/


    • Edited by jrv Thursday, October 26, 2017 2:05 PM
    Thursday, October 26, 2017 2:04 PM
  • This is the correct link for the current receiver for Windows:

    https://downloadplugins.citrix.com/Windows/CitrixReceiver.exe


    \_(ツ)_/

    Thursday, October 26, 2017 2:10 PM
  • This is the correct way to download a file:

    $url = 'https://downloadplugins.citrix.com/Windows/CitrixReceiver.exe'
    $saveTo = "$pwd\CitrixReceiver.exe"
    $wc = [System.Net.WebClient]::new()
    $wc.DownloadFile($url,$targetPath)
    


    \_(ツ)_/

    • Marked as answer by Byaku Friday, October 27, 2017 7:49 AM
    Thursday, October 26, 2017 2:14 PM
  • I played around with it for a while since it didn't work for me in the start.

    But i finally got it to work!

    Thank you.

    Friday, October 27, 2017 7:49 AM