More than 3 Start-Process in same ps1 gives error

Greetings,
My ps1 file has codes to open 3 instances of MS Access from different virtual drive locations. Each of the accdb is named differently as well. 2 of these open successfully but the 3rd instance gives an error. If I were to remark out the first 2 then the 3rd one works:

Error Message:

Start-Process : This command cannot be run completely because the system cannot find all the information required. At C:\Users\emeraudesystems\Desktop\ScriptGT\DataBankExtractor.ps1:11 char:24 + ... torStockApp=Start-Process -PassThru "E:\EmeraudeBI\DataBankExtractorS ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand

The property ‘ProcessorAffinity’ cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\emeraudesystems\Desktop\ScriptGT\DataBankExtractor.ps1:12 char:1

  • $DataExtractorStockApp.ProcessorAffinity=7
  •   + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : PropertyNotFound
    

CODE:

Copy-Item "E:\EmeraudeBI\DataBankExtractor.accdb" -Destination "E:\EmeraudeBI\DataBankExtractorGeneral.accdb"
$DataExtractorGeneralApp=Start-Process -PassThru "E:\EmeraudeBI\DataBankExtractorGeneral.accdb"
$DataExtractorGeneralApp.ProcessorAffinity=5

Copy-Item "E:\EmeraudeBI\DataBankExtractor.accdb" -Destination "E:\EmeraudeBI\DataBankExtractorBusinessStatistics.accdb"
$DataExtractorBusinessStatisticsApp=Start-Process -PassThru "E:\EmeraudeBI\DataBankExtractorBusinessStatistics.accdb"
$DataExtractorBusinessStatisticsApp.ProcessorAffinity=6

Copy-Item "E:\EmeraudeBI\DataBankExtractor.accdb" -Destination "E:\EmeraudeBI\DataBankExtractorStock.accdb"
$DataExtractorStockApp=Start-Process -PassThru "E:\EmeraudeBI\DataBankExtractorStock.accdb"
$DataExtractorStockApp.ProcessorAffinity=7

Biju Philip,
Welcome to the forum. :wave:t4:

Does it work when you use the correct / verbose way of starting the process?

Start-Process -FilePath '<path  to the Access executable>' -ArgumentList "E:\EmeraudeBI\DataBankExtractorStock.accdb" -PassThru
1 Like

Hello Olaf,

Perfect. Thank you for the great pointer.
Yes, you are correct.
Using the verbose way cleared a lot of my thinking too.

New Code:

# Specify the Fullpath and filename of the msaccess executable
$sAccess = "C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE"

Copy-Item "E:\EmeraudeBI\DataBankExtractor.accdb" -Destination "E:\EmeraudeBI\DataBankExtractorGeneral.accdb"
Set-Variable -Name "DataBankExtractorGeneral" -Value "E:\EmeraudeBI\DataBankExtractorGeneral.accdb"
$DataExtractorGeneralApp=(Start-Process -Filepath $sAccess -ArgumentList $DataBankExtractorGeneral -PassThru)
$DataExtractorGeneralApp.ProcessorAffinity=5

Copy-Item "E:\EmeraudeBI\DataBankExtractor.accdb" -Destination "E:\EmeraudeBI\DataBankExtractorBusinessStatistics.accdb"
Set-Variable -Name "DataBankExtractorBusinessStatistics" -Value "E:\EmeraudeBI\DataBankExtractorBusinessStatistics.accdb"
$DataExtractorBusinessStatisticsApp=(Start-Process -Filepath $sAccess -ArgumentList $DataBankExtractorBusinessStatistics -PassThru)
$DataExtractorBusinessStatisticsApp.ProcessorAffinity=6

Copy-Item "E:\EmeraudeBI\DataBankExtractor.accdb" -Destination "E:\EmeraudeBI\DataBankExtractorStock.accdb"
Set-Variable -Name "DataBankExtractorStock" -Value "E:\EmeraudeBI\DataBankExtractorStock.accdb"
$DataExtractorStockApp=(Start-Process -Filepath $sAccess -ArgumentList $DataBankExtractorStock -PassThru)
$DataExtractorStockApp.ProcessorAffinity=7

Best Regards,
Philip