-3

I have this to close IE when the Exit button is pressed:

function uf_LoginCloseWindow()
{
   window.close();
}

I want to do this:

function uf_LoginCloseWindow()
{
   c:\windows\system32\shutdown.exe -f -l
}

Can't seem to get it to work, I tried:

var objShell = new ActiveXObject("WScript.shell");
objShell.Run("C:\windows\system32\shutdown.exe");

All I can get out of the developer console is "The value of the property 'uf_LoginCloseWindow' is null or undefined, not a Function object"

Any ideas?

Dez
  • 5,702
  • 8
  • 42
  • 51
mgdicom
  • 3
  • 4
  • 1
    Possible duplicate of [Shutdown computer via web page](http://stackoverflow.com/questions/33628335/shutdown-computer-via-web-page) – Dez Apr 04 '17 at 17:57
  • you can do it with a file accosiation. make a bat file that shuts down. download a unknown mime type file from a page. when first prompted, choose "open", then browse to the bat file and choose it as an opener app (might need to type * in filename box first). Choose to remember the action. Now, everytime you spawn the download of that mime type, the bat will run and shutdown the system. you can use https://github.com/rndme/download/ to trigger a download of any mime; the contents of the file don't matter. – dandavis Apr 04 '17 at 18:45

1 Answers1

-1

You can close the window, but you can't close the running program as a whole with javascript alone. That is outside of the scope of javascript's security. Don't try to find a hack to make it happen, as it is a horrible thing to do for people browsing the net.

adamM
  • 1,116
  • 10
  • 29
  • 1
    Users won't be browsing the internet, they are using it to run an app which launches from the IE page -- I cut all LAN-WAN access; can I use a vbscript instead? – mgdicom Apr 04 '17 at 18:01
  • A signed Java applet could likely do it. And there is likely an activeX hack. But I would suggest a different path to this. Why do you need it to close the window? If you want "desktop app" features, why not just make a simple desktop app using C# or something similar? Best not force a browser to do something it is not intended on doing. – adamM Apr 04 '17 at 18:20
  • It's actually inteded to logoff the user from Windows when IE is closed -- this is being run as a RemoteApp but from a third party Citrix like program. The reason I want the Exit button to not only close IE but logoff the user is because there is a black screen for 20 seconds before the system does this itself -- really just need a smoother logoff. – mgdicom Apr 04 '17 at 19:58