the following code in .ts file in a electron application throws exception - cannot be read file.

private executeScript(): Promise<boolean> {
        return new Promise((resolve, reject) => {
            const path = require("path");
            execFile("cmd " + "/c " + "logs\\getdata_existing_install.bat", (error, stdout, stderr) => {
                    if (error) { reject(false); }
                    if (stdout) { resolve(true); }
                    if (stderr) { reject(false); }
                },
            );

the same when executed from command prompt works. Pls suggest.
        });
    };
Srilalitha vishnubhotlaAsked:
Who is Participating?
 
Jan LouwerensSoftware EngineerCommented:
It works from the command line when you're in one specific directory.

What is your current working directory when within the application? (You can use "cd" without any parameters to get the current working directory.)
1
 
Srilalitha vishnubhotlaAuthor Commented:
private executeScript(): Promise<boolean> {
        return new Promise((resolve, reject) => {
            const path = require("path");
            exec("cd ", (error, stdout, stderr) => {
                   if (error) { reject(false); }
                   if (stdout) {
                       execFile("config\\getdata_existing_install.bat",
                     (error1, stdout1, stderr1) => {
                        if (error1) { reject(false); }
                        if (stdout1) { resolve(true); }
                        if (stderr1) { reject(false); }
                    });
                       resolve(true);
                }
                   if (stderr) { reject(false); }
            });

        });
    };
0
 
Srilalitha vishnubhotlaAuthor Commented:
fixed issue.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.