Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

CommandNotFoundException when running the .bat files under PSDataExtract

Hi, I am first time user and get the following error when using PS v3.1

After adding transactions to the PortfolioSlicer-Source and got in the PSDataExtract to run the updatePSData, UpdatePSDataFromExcel and UpdatePSDataIntraday. This is when I get "command not found exception" error. See attachment.

Appreciate your time in looking into this for me.
Thank You

Comments

  • This message indicates that PowerShell scripts are not found. Usually, this happens when you try to execute your batch job (.bat file) but that .bat file "starts" in the folder where .ps1 files cannot be located in subfolder Scripts. That is your working directory is not what script is expecting.
    How are you executing .bat script? Are you opening windows explorer, going to the folder where .bat file is, confirming that there is a subfolder Scripts with .ps1 files?
  • Hi, this is the folder structure. And .ps1 files are in the Scripts folder.

  • Can you please do following:
    1. Start UpdatePSDataFromExcel.bat
    2. As soon as the previous step started press CTRL+C and post here screenshot of you cmd.exe file.

    I am expecting that first line in script execution will show where this script starts, example from my execution:



    In your case I expect that first line will be:
    c:\PortfolioSlicer\PSDataExtract powershell ....

  • Hi, this is the screenshot after I run step 1.
  • OK, so issue is that your .bat file starts in the folder:
    c:\WIndows\System32
    For some reason when you execute .bat file, it does not "registers" the location from where it starts. I have seen this happens when one executes "shortcut" to .bat file, instead of executing directly .bat file.
    It might be related to the fact that you execute this as "administrator" and that changes location.
    In any way, easiest solution for you would be to add following 2 lines to the top of your .bat files:
    c:
    cd \PortfolioSlicer\PSDataExtract


    These 2 lines first set environment to the location of the .bat files and then script should run fine.
  • Hi, thank you so much. The .bat files have now executed. I can now continue to explore the features. Appreciate your prompt response and time in resolving this. Cheers.
  • It appears I was able to reproduce your issue - it appears that when you run .bat files, you do an option: right mouse click->"Run as administrator". With this option you are changing execution environment and that is why script fails. You should be able to execute scripts just with simple double click, or right mouse click and then "Open" .
  • Yes, I dont know why I am used to right-clik and run as administrator. I did not even think of trying to run it the normal way! Simply double click has also worked without issues. Thank you again.
Sign In or Register to comment.