0
votes

I am trying to run a Powershell Script which contain the below Snippet of code from (Control M -Scheduler)

$excel = New-Object -ComObject Excel.Application

 $workbook=$excel.Workbooks.Open($ExcelPath,0,$false)

I am getting the below weird error

Exception calling "Open" with "3" argument(s): "Microsoft Excel cannot access the file 'Test_File.csv'. There are several possible reasons:

The file name or path does not exist. The file is being used by another program. The workbook you are trying to save has the same name as a currently open workbook."

With Same Id and Same environment when I tried to run from ISE, the code works like a charm So No idea what is going on

1
Has Control M's service account permissions to access the file? If not sure, start a shell with runas and check it out, or use Procmon. - vonPryz
yes it does have the access. - MohAsin
does it work with Windows scheduler ? - Kundan
Is the file already opened in Excel? - Theo
We have to use CTM , never tried windows scheduler - MohAsin

1 Answers

0
votes

Here is what needs to be done:

  1. Open cmd on the server.

  2. Navigate to the script location.

  3. Create folder using:

    mkdir C:\Windows\SysWOW64\config\systemprofile\Desktop
    
  4. Rerun the job Control-M

You can read more about it at: https://communities.bmc.com/docs/DOC-73715