0

I have a requirement from a customer to develop a Javascript application that allows users to pick a geographic location. Based off this selection they want to run a powershell script that resides locally on the desktop to run and change timezone and locale settings.

I have the map and ability to select the geographic location nailed down. I have tried use node-powershell and child_process to call the PS script but I don't think anything server side using NodeJS will work since it is all client side. I am struggling to find client side options that would work.

4
  • 1
    if this is intended to be browser based then no you won't be able to run a local executable or script on the user's machine. There's a good reason that websites can't do that! Best you can do is provide the Powershell script for download and then give the user instructions on how to execute it, if they so choose (you could wrap it in a nice friendly windows forms app of course, to make it easier for them). Commented Aug 2, 2019 at 15:51
  • What's the use case here though? Remote workers moving from location to location and wanting to set their PC to the local timezone? Commented Aug 2, 2019 at 15:52
  • You can do it the other way around - launch a GUI with PowerShell that renders the web page in a web control and then grab the selection from there before running the script to change locale/tz Commented Aug 2, 2019 at 16:16
  • Yes, remote workers needing to set their PC to local TZ and locale. Commented Aug 2, 2019 at 17:35

1 Answer 1

1

This is a bad idea. I recommend coding the whole thing in powershell. If you feel comfortable enough to violate the sacred sandbox there's an article about how you can use powershell to host javascript files and render them in a Internet Explorer here. It goes without saying that this is extremely insecure and if a competent tech lead or sysadmin catches you doing this, they will get really mad at you.

Javascript is designed to be used on the web, to tell a process living in a sandbox what to do under certain circumstances. It's recently been modified and re-purposed for node and other systems applications, but in my opinion it's still very weak and not a good substitute for systems programming yet.

Powershell is an extension of C#, and though there are some weaknesses, it carries almost as much power.

If I were undertaking a project, such as allowing remote users to change their time zone based on visuals, I would use the PictureBox Class to render a map of the world, and then attempt to translate the X,Y coordinates on the map to some sort of multi-dimensional array that translated those fields into timezones.

You could also put buttons on top of the map image, so that users press the button that corresponds to their location.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.