Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
start App using command line parameters
#1
follow these manual steps:
  1. Open the D:\RPA\XX folder.
  2. Launch cmd.exe in the current folder.
  3. Enter the command: pm2 start dist/index.js --name "AA"
  4. Successfully execute the program I need.
However, when I use the following code, it prompts the following error.
--------------------------------------------------------------------
Au.Types.AuException: Failed. %1 is not a valid Win32 application. (193).
1

--------------------------------------------------------------------

Is there any other simple solution?
Note: pm2 is a module of node.js, and it seems there is no pm2.exe file in the above folder.
https://i.ibb.co/F5jHsNZ/pm2.png
 
Code:
Copy      Help
// script "cmd2.cs"
//.
script.setup(trayIcon: true, sleepExit: true, exitKey: KKey.Pause);
//..
print.clear();

string nodePath = @"C:\Program Files\nodejs\node.exe";
string pm2Path = $@"{folders.RoamingAppData}\npm\pm2"; //C:\Users\Administrator\AppData\Roaming\npm

string curDir = @"D:\RPA\XX";
string arg = """
start dist/index.js --name "AA"
"""
;

int r = run.console(pm2Path,arg, curDir); 
print.it(r);

There is still an error message using the following code.
-------------------------------------------------------------------------
C:\Users\Administrator\AppData\Roaming\npm\pm2:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list
    at internalCompileFunction (node:internal/vm:128:18)
    at wrapSafe (node:internal/modules/cjs/loader:1280:20)
    at Module._compile (node:internal/modules/cjs/loader:1332:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
    at Module.load (node:internal/modules/cjs/loader:1206:32)
    at Module._load (node:internal/modules/cjs/loader:1022:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49

Node.js v20.12.2
1

-------------------------------------------------------------------------
Code:
Copy      Help
// script "cmd3.cs"
//.
script.setup(trayIcon: true, sleepExit: true, exitKey: KKey.Pause);
//..
print.clear();

string nodePath = @"C:\Program Files\nodejs\node.exe";
string pm2Path = $@"{folders.RoamingAppData}\npm\pm2"; //C:\Users\Administrator\AppData\Roaming\npm

string curDir = @"D:\RPA\XX";
string arg = $"""
{pm2Path} start dist/index.js --name "AA"
"""
;

int r = run.console(nodePath, arg, curDir);
print.it(r);
#2
@Davider, not sure if this will help, but on my system the pm2.exe is at
 
Code:
Copy      Help
C:\Users\Administrator\AppData\Roaming\npm\node_modules\pm2-windows-service\src\daemon\pm2.exe
Perhaps change the offending 'pm2' line to this:
Code:
Copy      Help
string pm2Path = $@"{folders.RoamingAppData}\npm\node_modules\pm2-windows-service\src\daemon\pm2";
#3
Thanks for your help.
I couldn't find the pm2.exe file in the specified path.
C:\Users\Administrator\AppData\Roaming\npm\node_modules\pm2-windows-service\src\daemon\pm2.exe

The folder containing this file should exist in the environment variables. There might be a simpler method available.
#4
I should have posted this:
Code:
Copy      Help
C:\Users\<your user here>\AppData\Roaming\npm\node_modules\pm2-windows-service\src\daemon\pm2.exe
Sorry about that.
If you have Everything.exe or some other file search prog on your computer, you might check to see if your version of node installed pm2.exe somewhere else.
#5
I still haven't solved the problem above. I don't know what's causing the issue...

The location of pm2 on each computer is different, but it definitely exists in the environment variable folder.
#6
In LA, is there a function similar to SetCurDir(QM: Changes current directory)? I'm stuck on the issue above.
#7
LA no.
.NET yes.
#8
Using the AI link you provided, Davider:
 
Code:
Copy      Help
using System;
using System.IO;

class Program
{
    static void Main()
    {
        // Path to the new current directory
        string newCurrentDirectory = @"C:\Your\New\Path";

        // Check if the directory exists before setting it
        if (Directory.Exists(newCurrentDirectory))
        {
            // Set the current directory
            Directory.SetCurrentDirectory(newCurrentDirectory);
            Console.WriteLine("The current directory has been set to: " + Directory.GetCurrentDirectory());
        }
        else
        {
            Console.WriteLine("The specified directory does not exist.");
        }
    }
}
#9
thank you, Gintaras, burque505


Forum Jump:


Users browsing this thread: 2 Guest(s)