Set environment variables using js

//  Debug function  
function show(msg)
{
wsh = new ActiveXObject("WScript.Shell");
wsh.Popup(msg);
}
// Perform  
//eval
//try {
// Debug("dkjkljei");
//} catch (e) {
//}

/**
wsh = new ActiveXObject("WScript.Shell");
 Gets the user environment variables  
wsh.Environment("user").Item(name);
 Set the user environment variables  
wsh.Environment("user").Item(name) = value;
 Delete user environment variables  
wsh.Environment("user").Remove(name);
 Gets the system environment variables  
wsh.Environment("system").Item(name);
 Set the system environment variables  
wsh.Environment("system").Item(name) = value;
*/
function addEnvVar(sys, obj, value) {
wsh = new ActiveXObject("WScript.Shell");
wsh.Environment(sys).Item(obj) = value;
}
function delEnvVar(obj) {
wsh = new ActiveXObject("WScript.Shell");
wsh.Environment("user").Remove(obj);
}
function getEnvVar(sys, obj) {
wsh = new ActiveXObject("WScript.Shell");
return(wsh.Environment(sys).Item(obj));
}
/**
Set ws=WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(ws.CurrentDirectory)
Set fc = f.Files
For Each f1 in fc
   if right(f1.name,len(f1.name)-InStrRev(f1.name,"."))="reg" then ws.run "regedit /s """&f1.name&""""
Next
*/
function showDir() {
var fso, f, fc, s;
wsh = new ActiveXObject("WScript.Shell");
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFolder(wsh.CurrentDirectory);
fc = new Enumerator(f.files);
s = "";
var regValue = new RegExp(".java$","i");
for (; !fc.atEnd(); fc.moveNext()) {
  if (regValue.test(fc.item())) {
   var ff = fc.item();
   s += ff.Name;
   s += "\n";
  }
}
return(s);
}
var jdk = "d:\\java\\jdk";
function setJDK(obj) {
// Set  java_home
addEnvVar("system", "java_home", obj);
var path = getEnvVar("system", "path");
var pathbak = getEnvVar("system", "pathbak");
// Determine the existence of pathbak, not the Add  
if (pathbak == "") {
  addEnvVar("system", "pathbak", path);
}
// Set  path
addEnvVar("system", "path", path + ";%java_home%\\bin");

var cp, fso, f, fc, ff;
wsh = new ActiveXObject("WScript.Shell");
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFolder(obj + "\\lib");
fc = new Enumerator(f.files);
cp = ".;";
var regValue = new RegExp(".jar$","i");
for (; !fc.atEnd(); fc.moveNext()) {
  ff = fc.item();
  if (regValue.test(ff.name)) {
   cp += "%java_home%\\lib\\" + ff.name + ";";
  }
}
// Set  classpath
addEnvVar("system", "classpath", cp);
}
eval(run());
function run() {
wsh = new ActiveXObject("WScript.Shell");
wsh.run("regedit");
}

Set environment variables using js
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Set environment variables using js

  • Msxml2.XMLHTTP version problem

    Projects with an import feature prototype.js of Ajax functionality to update the prompt, the code is very simple, do not have the framework of the background on a jsp to output Text, future use of timers and to update the page Ajax.request encountere ...

  • IBM Ajax Tutorial Series

    Links: http://ibm.csdn.net/ISN_J.aspx?action=JMP&pointid=1550 Part 10: Using JSON for data transmission In the asynchronous application to send and receive information, you can choose to plain text and XML as data format. Ajax grasp of this issue ...

  • jquery ajax example

    1. Check js file $. ajax (( type: "GET", url: "test.js", dataType: "script" )) 2.post data $. ajax (( type: "POST", url: "xxxx", data: "name = zhaoaiqing & age = 25", success: function ( ...

  • eclipse Hibernate proposals

    Error: The 'Hibernate proposals' proposal computer from the' org.hibernate.eclipse.jdt.ui 'plug-in dod not complete normally. Unable to instantiate the extension. To Avoid this message, disable the 'org.hibernate.eclipse.jdt.ui ...

  • Strength of live practice teaching materials, suitable for each person team look - UFIDA Hua Table CTO talk about "out of the software factory"

    A few months ago, on reading "Going the software factory," one book, not yet published at that time, it can be considered the reference of the watch. Although the language rather uneventful, but the contents of people really can not but carry on

  • Workspace run under different Eclipse

    Now do live more and more often required to use eclipse in java and ruby & rails project conducted between the tangential shear from the past, because in the rails project used a coloring Aptana preferences, the results open the java project sour ...

  • Software development sunflower Baodian [reprint]

    Master the ability to reuse code very familiar with the new API's fast. This is because, he once used a lot of the API, have a lot of reusable code. He knows what is available and what is deficient. He has been using Qt, also used by gtk +, also used

  • hibernate (jpa) composite primary key annotation statement Ways

    In the design of the database tables are designed with a composite primary key of the table, that table's record by more than one field joint identification, such as: Table CREATE TABLE TB_HOUR_DATA ( STAT_DATE DATE NOT NULL, PATH_ID NUMBER(20) NOT NULL,

  • can not be represented as java.sql.Timestamp

    Development of procedures for the use of hibernate when, some time there is no need to fill in the fields, but after the hibernate query time reported "Java.sql.SQLException: Value'0000-00-00 'can not be represented as java.sql.Timestamp ...

  • Struts2 + hibernate + spring problem user log in

    dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries