0

Have a requirement of using batch file in Cognos to upload the output in SharePoint by using Windows batch file we are scheduling.

Here is my script:

@ECHO OFF

IF EXIST "D:\Dev\close report name-en-in" Call Powershell.exe -executionpolicy remotesigned -File 'D:\Dev\close\pwrshell.ps1'

GOTO END

:END

PowerShell script is used for uploading the script from source.

After running batch file the output is not uploaded to SharePoint (PowerShell script works fine when running alone).

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
vck
  • 1

1 Answers1

0

Not sure if this works or not, but there is a simple error in your script.

Call Powershell.exe -executionpolicy remotesigned -File 'D:\Dev\close\pwrshell.ps1'

should be

Powershell.exe -executionpolicy remotesigned -File 'D:\Dev\close\pwrshell.ps1'

Here's some better ways to end the file.

exit /b [errorlevel]

This stops the script, and optionally set an errorlevel.

goto :eof

We don't need :EOF for this to work, goto :eof works standalone.

  • `call` just doesn't do anything here, but it's not an error (the keyword is for invoking other batch scripts in a way that they return to the caller after execution). `goto END`/`:END` also isn't incorrect, but doesn't have a purpose, b/c the script would behave exactly the same with the 2 lines removed. – Ansgar Wiechers Jul 21 '17 at 07:14
  • `call` is used to call a subroutine or batch file, not designed for a powershell script –  Jul 21 '17 at 07:25
  • I'm aware of that. It still doesn't hurt when you use it on executables. That's not the issue the OP is facing. – Ansgar Wiechers Jul 21 '17 at 07:27