Modifying script behavior according to computer it runs on

Started by ubacher, February 12, 2019, 03:41:12 PM

Previous topic - Next topic

ubacher

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?

Mario

The /info endpoint returns a lot of useful information, including the machineName.
See the Info App for details and usage.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook


Carlo Didier

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.

Mario

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.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook