Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript cannot be run in InstallShield Express?

I am using InstallShield Express to create a setup project.

I try to add a custom action for Uninstallation, before "System Changes".

The custom action is a JavaScript which will open a window, as below:

window.open("https://www.example.com/", "_blank");

However, when I try to uninstall the program, I get an error said "Microsoft JScript Runtime Error, 'window' is not defined.

Why?

Update:

Finally I choose to use a MSI DLL instead of the script to solve the problem. What should I do with this question? THanks.

like image 701
alancc Avatar asked Apr 23 '20 00:04

alancc


1 Answers

The windows object does not exist in NodeJS. However, if you just want to declare a global variable to use it later, you can add the open method in the global object like:

glboal.open = function whatever(url, param2){

// does the stuff you want

};

And then you can use it this way:

conosle.log(global.open('https://www.example.com/','_blank')); 

But i still do not recommend creating a global variable for this. Make a function in a file and import it when you need it. Global variables can cause coupling, and make code harder to read. Also, this variable will exist the entire lifetime of the application, and this might not be good if you are going to make more of them.

If you want to read more about why global variables are bad: https://wiki.c2.com/?GlobalVariablesAreBad

like image 133
Pedro Henrique Bufulin Avatar answered Nov 19 '22 11:11

Pedro Henrique Bufulin