Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.18 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Security.Principal;
  4. using System.Xml;
  5.  
  6. namespace AdobeTrialAuto_Extender {
  7. class Program {
  8.  
  9. static private XmlDocument changeTrialSerial(String path) {
  10. //Loads and modifies the xml (loops through, finds the TrialSerialNumber, and adds 100 to it, to renew the trial).
  11. XmlDocument applicationXml = new XmlDocument();
  12. applicationXml.Load(path);
  13. foreach (XmlNode testTrial in applicationXml.GetElementsByTagName("Data")) {
  14. if (testTrial.Attributes.GetNamedItem("key").Value.Equals("TrialSerialNumber")) {
  15. Console.WriteLine("Initial TrialSerialNumber: " + testTrial.InnerText);
  16. testTrial.InnerText = (Decimal.Parse(testTrial.InnerText) + 100).ToString("########################");
  17. Console.WriteLine("New TrialSerialNumber: " + Decimal.Parse(testTrial.InnerText).ToString("########################"));
  18. return applicationXml;
  19. }
  20. }
  21. return null;
  22. }
  23.  
  24. static void Main(string[] args) {
  25. //Checks if the program has somehow not been run as administrator, exits if it has not.
  26. if (!new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator)) {
  27. Console.WriteLine("Program has not been run as adminstrator, press enter to quit, then run again as an administrator.");
  28. Console.ReadLine();
  29. Environment.Exit(5);
  30. }
  31.  
  32. //Non-Interactive Mode
  33. if (args.Length == 1) {
  34. Console.WriteLine("Non-Interactive Mode");
  35.  
  36. //Displays legal warnings.
  37. Console.ForegroundColor = ConsoleColor.Red;
  38. Console.WriteLine("WARNING -- USE OF THIS PROGRAM VIOLATES ADOBE'S TERMS OF USE.");
  39. Console.WriteLine("USING THIS PROGRAM MAY LAND YOU IN LEGAL TROUBLE, FOR WHICH THE SOFTWARE'S AUTHOR ACCEPTS NO RESPONSIBILITY FOR.");
  40. Console.WriteLine("THIS SOFTWARE COMES WITHOUT WARRANTY OF ANY KIND, EVEN THE IMPLIED WARRANTY OF FITNESS FOR PURPOSE.");
  41. Console.ForegroundColor = ConsoleColor.White;
  42.  
  43. XmlDocument toSave = changeTrialSerial(args[0]);
  44.  
  45. //Saves then exits.
  46. toSave.Save(args[0]);
  47. Console.WriteLine("Saved successfully.");
  48. Environment.Exit(0);
  49. }
  50. //Displays legal warnings.
  51. Console.ForegroundColor = ConsoleColor.Red;
  52. Console.WriteLine("WARNING -- USE OF THIS PROGRAM VIOLATES ADOBE'S TERMS OF USE.");
  53. Console.WriteLine("USING THIS PROGRAM MAY LAND YOU IN LEGAL TROUBLE, FOR WHICH THE SOFTWARE'S AUTHOR ACCEPTS NO RESPONSIBILITY FOR.");
  54. Console.WriteLine("THIS SOFTWARE COMES WITHOUT WARRANTY OF ANY KIND, EVEN THE IMPLIED WARRANTY OF FITNESS FOR PURPOSE.");
  55.  
  56.  
  57. //Asks for the root directory for Adobe programs.
  58. Console.ForegroundColor = ConsoleColor.White;
  59. Console.WriteLine("Please enter your Adobe directory (e.g. C:\\Program Files\\Adobe\\):");
  60. String AdobeDir = Console.ReadLine();
  61. //Gets the Adobe programs present, and asks the user which one they would like to modify.
  62. String[] AdobePrograms = Directory.GetDirectories(AdobeDir);
  63. int numProgram = 0;
  64. foreach (String program in AdobePrograms) {
  65. Console.WriteLine("[" + numProgram + "] " + program.Substring(AdobeDir.Length));
  66. numProgram++;
  67. }
  68. Console.WriteLine("Select a number to extend its trial.");
  69. int choice = int.Parse(Console.ReadLine());
  70.  
  71. XmlDocument newXml = changeTrialSerial(AdobePrograms[choice] + "\\AMT\\application.xml");
  72.  
  73.  
  74. //Saves, waits for a key, then exits.
  75. newXml.Save(AdobePrograms[choice] + "\\AMT\\application.xml");
  76. Console.WriteLine("Saved successfully. Press any key to exit.");
  77. Console.ReadKey();
  78. Environment.Exit(0);
  79. }
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement