cmdinstaller.Install Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nc-activate Show documentation
Show all versions of nc-activate Show documentation
internal package of Alachisoft.
/*
* Main.java
*
* Created on October 26, 2006, 10:16 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package cmdinstaller;
//~--- JDK imports ------------------------------------------------------------
import com.alachisoft.ncache.licensing.config.InfoType;
import com.alachisoft.ncache.ncactivate.utils.RegKeys;
import com.alachisoft.ncache.ncactivate.utils.RegUtil;
import java.io.IOException;
import java.util.HashMap;
import java.util.StringTokenizer;
//~--- classes ----------------------------------------------------------------
/**
* @author Administrator
*/
public class Install {
private static String email;
private static String fname;
private static String lname;
private static String edition = "";
private static HashMap userArgs = new HashMap();
//~--- constructors -------------------------------------------------------
//~--- methods ------------------------------------------------------------
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
String in = "f=jack";
/* "l= ;" +
"publisher=java-samples.com;" +
"copyright=2007;";*/
// get the user info.
for (int i = 0; i < args.length; i++) {
StringTokenizer st = new StringTokenizer(args[i], "=");
if (st.countTokens() != 2) {
System.err.println("Inalid Parameters");
return;
}
while (st.hasMoreTokens()) {
String key = st.nextToken();
String val = st.nextToken();
userArgs.put(key, val);
}
}
boolean dontSetupUserInfo = true;//userArgs.get("d") != null ? true : false;
if (!dontSetupUserInfo) {
try {
getUserInfo();
} catch (IOException ex) {
System.out.println("error: " + ex.getMessage());
return;
}
}
try {
String installCode = userArgs.get("i") != null ? userArgs.get("i").toString() : "";
if (!installCode.isEmpty()) {
StubInitializer.InitializeStub(userArgs.get("i").toString());
} else {
System.err.println("Install code is empty");
}
if (!dontSetupUserInfo) {
// setup information in reg file
setupUserInfo();
}
System.out.println("Installation completed successfully.\n");
} catch (Exception ex) {
// ex.printStackTrace();
System.err.println("error: " + ex.getMessage() + ex.toString());
}
}
private static void setupUserInfo() {
RegUtil.LoadRegistry();
RegUtil.setKey(InfoType.USER, RegKeys.FirstName, fname.trim());
RegUtil.setKey(InfoType.USER, RegKeys.LastName, lname.trim());
RegUtil.setKey(InfoType.USER, RegKeys.Email, email.trim());
RegUtil.StoreRegistry();
}
private static void getUserInfo() throws IOException {
if (userArgs.containsKey("f")) {
fname = userArgs.get("f").toString().trim();
}
if (userArgs.containsKey("l")) {
lname = userArgs.get("l").toString().trim();
}
if (userArgs.containsKey("e")) {
email = userArgs.get("e").toString().trim();
}
}
}
//~ Formatted by Jindent --- http://www.jindent.com
© 2015 - 2024 Weber Informatics LLC | Privacy Policy