Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Start-Process : This command cannot be run due to the error: The system cannot find the file specified.

$
0
0

Hi, 

I need some help with my script. It copies the file to the remote laptops but when it needs to install the .exe it fails.

If I run 1 line at the time in Powershell ISE, then it works. Somebody has an idea why it doesn't work or can help me on the right way?

Script: 

    

$laptops = Get-Content -Path "C:\Users\bruyld01\Documents\STEPSTONE\Powershell\SAP\LaptopList.txt"

foreach ($laptop in $laptops)
    {
    Copy-Item "C:\Users\bruyld01\Desktop\SAP_Business_ByDesign_Add-In_for_Microsoft_Outlook_V5.exe" -Destination \\$laptop\C$\
    Enter-PSSession $laptop
    $version = Get-WmiObject -Class Win32_Product | where {$_.Name -like "*SAP Business*"} | Select-Object Version

    if ($version -ne "135.0.2071.1047")
        {
        Start-Process -Filepath "C:\SAP_Business_ByDesign_Add-In_for_Microsoft_Outlook_V5.exe" -ArgumentList "/quiet"
        }
    else
        {
        Write-Host "SAP outlook add-in is up to date!" -ForegroundColor Green
        }

    Exit-PSSession
    }


Error message:

Start-Process : This command cannot be run due to the error: The system cannot find the file specified.
At line:2 char:1
+ Start-Process -Filepath "C:\SAP_Business_ByDesign_Add-In_for_Microsoft_Outlook_V ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand

Thanks, 

Dimitri


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>