Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Security.Principal;
- using System.Xml;
- namespace AdobeTrialAuto_Extender {
- class Program {
- static private XmlDocument changeTrialSerial(String path) {
- //Loads and modifies the xml (loops through, finds the TrialSerialNumber, and adds 100 to it, to renew the trial).
- XmlDocument applicationXml = new XmlDocument();
- applicationXml.Load(path);
- foreach (XmlNode testTrial in applicationXml.GetElementsByTagName("Data")) {
- if (testTrial.Attributes.GetNamedItem("key").Value.Equals("TrialSerialNumber")) {
- Console.WriteLine("Initial TrialSerialNumber: " + testTrial.InnerText);
- testTrial.InnerText = (Decimal.Parse(testTrial.InnerText) + 100).ToString("########################");
- Console.WriteLine("New TrialSerialNumber: " + Decimal.Parse(testTrial.InnerText).ToString("########################"));
- return applicationXml;
- }
- }
- return null;
- }
- static void Main(string[] args) {
- //Checks if the program has somehow not been run as administrator, exits if it has not.
- if (!new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator)) {
- Console.WriteLine("Program has not been run as adminstrator, press enter to quit, then run again as an administrator.");
- Console.ReadLine();
- Environment.Exit(5);
- }
- //Non-Interactive Mode
- if (args.Length == 1) {
- Console.WriteLine("Non-Interactive Mode");
- //Displays legal warnings.
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("WARNING -- USE OF THIS PROGRAM VIOLATES ADOBE'S TERMS OF USE.");
- Console.WriteLine("USING THIS PROGRAM MAY LAND YOU IN LEGAL TROUBLE, FOR WHICH THE SOFTWARE'S AUTHOR ACCEPTS NO RESPONSIBILITY FOR.");
- Console.WriteLine("THIS SOFTWARE COMES WITHOUT WARRANTY OF ANY KIND, EVEN THE IMPLIED WARRANTY OF FITNESS FOR PURPOSE.");
- Console.ForegroundColor = ConsoleColor.White;
- XmlDocument toSave = changeTrialSerial(args[0]);
- //Saves then exits.
- toSave.Save(args[0]);
- Console.WriteLine("Saved successfully.");
- Environment.Exit(0);
- }
- //Displays legal warnings.
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("WARNING -- USE OF THIS PROGRAM VIOLATES ADOBE'S TERMS OF USE.");
- Console.WriteLine("USING THIS PROGRAM MAY LAND YOU IN LEGAL TROUBLE, FOR WHICH THE SOFTWARE'S AUTHOR ACCEPTS NO RESPONSIBILITY FOR.");
- Console.WriteLine("THIS SOFTWARE COMES WITHOUT WARRANTY OF ANY KIND, EVEN THE IMPLIED WARRANTY OF FITNESS FOR PURPOSE.");
- //Asks for the root directory for Adobe programs.
- Console.ForegroundColor = ConsoleColor.White;
- Console.WriteLine("Please enter your Adobe directory (e.g. C:\\Program Files\\Adobe\\):");
- String AdobeDir = Console.ReadLine();
- //Gets the Adobe programs present, and asks the user which one they would like to modify.
- String[] AdobePrograms = Directory.GetDirectories(AdobeDir);
- int numProgram = 0;
- foreach (String program in AdobePrograms) {
- Console.WriteLine("[" + numProgram + "] " + program.Substring(AdobeDir.Length));
- numProgram++;
- }
- Console.WriteLine("Select a number to extend its trial.");
- int choice = int.Parse(Console.ReadLine());
- XmlDocument newXml = changeTrialSerial(AdobePrograms[choice] + "\\AMT\\application.xml");
- //Saves, waits for a key, then exits.
- newXml.Save(AdobePrograms[choice] + "\\AMT\\application.xml");
- Console.WriteLine("Saved successfully. Press any key to exit.");
- Console.ReadKey();
- Environment.Exit(0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement