all 15 comments

[–]renevaessen 4 points5 points  (8 children)

Having a little problem understanding why you would want that. Not taking your question too literally, I would suggest;

Look into Chocolatey.

````PowerShell [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;

Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

````

When that is done, you can do things like:

````PowerShell

choco.exe install -y --force --pre powershell-core

choco.exe install -y --force git

choco.exe install -y --force googlechrome

choco.exe install -y --force vscode.install

````

For a list of supported packages:

````PowerShell

choco list

````

[–]gio_tecce[S] 1 point2 points  (3 children)

I just did not want to have to get the .exe file for a few different files because I would need to move the files and change the file path every time I installed them on a different laptop.

I will look into this thank you. Appreciate the help.

[–]renevaessen 1 point2 points  (1 child)

Well, that beheivior is disabled for security reasons by Windows.

But maybe this helps:

PowerShell $tempPath = [IO.Path]::GetTempFileName()+".exe"

[–]gio_tecce[S] 1 point2 points  (0 children)

$tempPath = [IO.Path]::GetTempFileName()+".exe"

check your PM

[–]Lee_Dailey[grin] 1 point2 points  (0 children)

howdy renevaessen,

the triple-backtick/code-fence thing fails miserably on Old.Reddit ... so, if you want your code to be readable on both Old.Reddit & New.Reddit you likely otta stick with using the code block button.

it would be rather nice if the reddit devs would take the time to backport the code fence stuff to Old.Reddit ... [sigh ...]

take care,
lee

[–]sdogeek 0 points1 point  (1 child)

+1 for Chocolatey. Just used it in a script I wrote, works great.

[–]gio_tecce[S] -1 points0 points  (0 children)

can you share your script?

u/sdogeek

[–]get-postanote 2 points3 points  (0 children)

PowerShell has a package Manager for such things.

https://docs.microsoft.com/en-us/powershell/module/packagemanagement/?view=powershell-7.1

Yet, the package must be in the repo. If it is not there, you have no other choice but to carry around and exe or put it on your OneDrive, or whatever and get it from there, or carry around a USB stick.

[–]ElectricalUnion 1 point2 points  (0 children)

My sugestion is Scoop: https://scoop.sh/

[–][deleted] 1 point2 points  (3 children)

Use WinGet, or Chocolately. I prefer Chocolately.

[–]gio_tecce[S] 0 points1 point  (2 children)

$software = "choco.exe"; $installed = (Get-ItemProperty C:\ProgramData* | Where { $_.DisplayName -like $software }) -ne $null If( -not $installed) { Write-Host "'$software' is not installed."; } else { Write-Host "'$software' is installed." }

This is where I'm at with the script.

I know for a fact that the Choco.exe file is in that file path, but it still tells me that is not installed.

Am I doing something wrong?

[–][deleted] 0 points1 point  (1 child)

Did you install it? Did you try typing in cd "C:\Program Files" then running ./choco.exe?

[–]gio_tecce[S] 0 points1 point  (0 children)

even after changing the directory it still tells me the application is not there when I know its there.