System.util.perspective TypeError expected 1 args; got 2

Not sure what’s going on here. When I call something super simple from Perspective button:

system.util.execute(['notepad.exe'])

I get this error:
image

(And yes I realise that this will execute on the gateway and it’s not what I want to do. I’m actually trying to execute a batch file but this looked easier)

Any ideas?
Also, how would I execute a batch file? Do I have to call it through cmd?
e.g.

system.util.execute(['cmd', '/c', 'c:/folder/thing.bat'])

?

Actually, it worked… the batch file ran, but it just produced an error for some reason??

Next question, is there any way to run the batch file with admin rights? :slight_smile: I’m guessing not…

Maybe this:
Create a bat shortcut, and then right-click the shortcut — > Properties > Advanced — > run as administrator.

Or if you want to get fancy:
How to make bat batch run with administrator’s permission

It’s going to run as the same user as the gateway service. In Linux I would use an SSH key with a program restriction to launch into a target user (even root) to run the script.

using a shortcut(.lnk) you can not run a batchfile with parameters tho

easiest is to run the gatewayservice as an adminuser

I’ve had best results by writing the .bat file from Ignition before executing it.
That also guarantees that the content of the .bat file is exactly where and what it is expected to be.

1 Like

Umm… not true
image

and now try
test.lnk "lnk params with spaces" "does this work?"

Yes.
image

hmm that didnt work for me when i tried it a while ago…
ah i also had an absolute path to the lnk with spaces

"test.lnk" "with spaces" "param2"
"C:\Program Files\test.lnk" "with spaces" "param2"

and maybe it just didnt go through ignition idk

Don’t know what to tell you.

2 Likes

Weird, i failed a bunch trying that the other week, maybe i did somethingn else wrong xD
i kept trying to run the lnk with a path to an image as param and it just didnt work but if i used the bat directly it worked fine.

i also found a forum somewhere that they said that params dont work on lnks, idk
best to test if it works anyways i guess xd

ah maybe its because i ran the cmd from igntion with cmd c/ ? because this seems to happen in the cmdln


Altho that should happen with batfile too idk xD… thats why i avoid spaces as much as possible lol
i have no idea how it gets to run the batfile tho if it thinks half of the folder\test.lnk" is a param xD