photools.com Community

IMatch Discussion Boards => IMatch Scripting and Apps => Topic started by: ubacher on February 12, 2019, 03:41:12 PM

Title: Modifying script behavior according to computer it runs on
Post by: ubacher on February 12, 2019, 03:41:12 PM
I would like to have some apps behave differently when they run on the laptop instead of the desktop.
How can I find out what computer I run on?  Only thing I could find which might allow system identification
is a call to v1/utility/registry.  (Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName)
Any better way?
Title: Re: Modifying script behavior according to computer it runs on
Post by: Mario on February 12, 2019, 03:55:41 PM
The /info endpoint returns a lot of useful information, including the machineName.
See the Info App for details and usage.
Title: Re: Modifying script behavior according to computer it runs on
Post by: ubacher on February 12, 2019, 09:15:15 PM
Perfect, Thank you.
Title: Re: Modifying script behavior according to computer it runs on
Post by: Carlo Didier on February 14, 2019, 11:07:30 AM
If you want to check independently from IWS, the script could simply read the environment variable "COMPUTERNAME".
Don't know the syntax for javascript, but you should be able to find that.
Title: Re: Modifying script behavior according to computer it runs on
Post by: Mario on February 14, 2019, 11:39:33 AM
JavaScript apps run in the browser sandbox, which prevents access to environment variables and other potentially harmful things.

If you need to access environment variables or other system functions, use Node.js or Python or ,NET or PowerShell or whatever programming language you prefer. They all work with IMWS much in the same way as native IMatch apps do.

Or you call a PowerShell script from an IMatch app. So many ways to do so many things.

IMWS and IMatch provide a range of low-level functions, like reading/writing files, access to system directories etc. The machine name (computer name) is delivered by the /info endpoint, among user system information.

Check out the /info /process /filesystem endpoints in the documentation for a full list.