I’m new to Powershell so bear with me.
I have an exe file that I run with powershell, that exe file imports data from a database and saves csv files. Takes roughly 30 seconds. However, after it finishes, Powershell never moves on to the next line of code. It stays waiting for the exe to do something.
I’m trying to run the exe, then open Excel and run a macro to process the CSV files. Currently it runs the exe, but never moves on to Excel. I thought of a timer, but couldn’t get it to work despite by Googling. Any help would be appreciated.
$d1 = [DateTime]::Today.ToString("yyyy-MM-dd") $d2 = [DateTime]::Today.AddDays(-7).ToString("yyyy-MM-dd") cmd /K "C:Usersuser1Desktopprogram.exe -s 433.432.61.23 -f $d2 -l $d1 -i 300" # start Excel $excel = New-Object -comobject Excel.Application #open file $FilePath = 'C:Usersuser1DocumentsMeasurements SyncDataPull.xlsm' $workbook = $excel.Workbooks.Open($FilePath) #make it visible (just to check what is happening) $excel.Visible = $true #access the Application object and run a macro $app = $excel.Application $app.Run("Macrd2") $excel.Quit()