Skip to content

Instantly share code, notes, and snippets.

@balazsbohonyi
Created July 19, 2025 18:10
Show Gist options
  • Save balazsbohonyi/02dcd056e23d0c6db186490c428745bd to your computer and use it in GitHub Desktop.
Save balazsbohonyi/02dcd056e23d0c6db186490c428745bd to your computer and use it in GitHub Desktop.
Jetbeans Trials reset
#!/usr/bin/env python3
"""
JetBrains Trial Reset Tool
A Python implementation that resets trial periods for JetBrains IDEs
"""
import os
import platform
import subprocess
import shutil
import glob
from pathlib import Path
class JetBrainsTrialReset:
def __init__(self):
self.system = platform.system().lower()
self.jetbrains_products = [
"IntelliJIdea",
"CLion",
"DataGrip",
"GoLand",
"PhpStorm",
"PyCharm",
"ReSharper",
"Rider",
"RubyMine",
"WebStorm",
"Datalore",
"ReSharperC"
]
def reset_windows(self):
"""Reset JetBrains trial on Windows"""
print("🪟 Resetting JetBrains trial on Windows...")
# Remove JavaSoft registry key
try:
result = subprocess.run([
'reg', 'delete',
'HKEY_CURRENT_USER\\Software\\JavaSoft',
'/f'
], capture_output=True, text=True)
if result.returncode == 0:
print("✅ Registry key HKEY_CURRENT_USER\\Software\\JavaSoft removed successfully")
else:
print("ℹ️ Registry key might already be removed")
except Exception as e:
print(f"❌ Error removing registry key: {e}")
# Remove PermanentUserId file
permanent_user_id_path = os.path.expandvars(r"%APPDATA%\JetBrains\PermanentUserId")
try:
if os.path.exists(permanent_user_id_path):
os.remove(permanent_user_id_path)
print("✅ PermanentUserId file removed successfully")
else:
print("ℹ️ PermanentUserId file not found")
except Exception as e:
print(f"❌ Error removing PermanentUserId: {e}")
def reset_mac(self):
"""Reset JetBrains trial on macOS"""
print("🍎 Resetting JetBrains trial on macOS...")
home = Path.home()
# Remove evaluation keys and preference files for each product
for product in self.jetbrains_products:
# Old path evaluation keys
old_eval_pattern = home / f"Library/Preferences/{product}*/eval"
for eval_path in glob.glob(str(old_eval_pattern)):
try:
shutil.rmtree(eval_path, ignore_errors=True)
print(f"✅ Removed old evaluation key for {product}")
except Exception as e:
print(f"❌ Error removing old eval key for {product}: {e}")
# New path evaluation keys
new_eval_pattern = home / f"Library/Application Support/JetBrains/{product}*/eval"
for eval_path in glob.glob(str(new_eval_pattern)):
try:
shutil.rmtree(eval_path, ignore_errors=True)
print(f"✅ Removed new evaluation key for {product}")
except Exception as e:
print(f"❌ Error removing new eval key for {product}: {e}")
# Remove evlsprt from options.xml (old path)
old_options_pattern = home / f"Library/Preferences/{product}*/options/other.xml"
for options_file in glob.glob(str(old_options_pattern)):
try:
self._remove_evlsprt_from_file(options_file)
print(f"✅ Cleaned evlsprt from old options file for {product}")
except Exception as e:
print(f"❌ Error cleaning old options for {product}: {e}")
# Remove evlsprt from options.xml (new path)
new_options_pattern = home / f"Library/Application Support/JetBrains/{product}*/options/other.xml"
for options_file in glob.glob(str(new_options_pattern)):
try:
self._remove_evlsprt_from_file(options_file)
print(f"✅ Cleaned evlsprt from new options file for {product}")
except Exception as e:
print(f"❌ Error cleaning new options for {product}: {e}")
# Remove preference files
pref_patterns = [
"Library/Preferences/com.apple.java.util.prefs.plist",
"Library/Preferences/com.jetbrains.*.plist",
"Library/Preferences/jetbrains.*.*.plist"
]
for pattern in pref_patterns:
pref_path = home / pattern
for pref_file in glob.glob(str(pref_path)):
try:
os.remove(pref_file)
print(f"✅ Removed preference file: {os.path.basename(pref_file)}")
except Exception as e:
print(f"❌ Error removing {pref_file}: {e}")
# Restart cfprefsd
try:
subprocess.run(['killall', 'cfprefsd'], check=False)
print("✅ Restarted cfprefsd")
except Exception as e:
print(f"❌ Error restarting cfprefsd: {e}")
def reset_linux(self):
"""Reset JetBrains trial on Linux"""
print("🐧 Resetting JetBrains trial on Linux...")
home = Path.home()
config_path = home / ".config/JetBrains"
for product in self.jetbrains_products:
product_patterns = list(config_path.glob(f"{product}*"))
for product_dir in product_patterns:
if product_dir.is_dir():
print(f"🔧 Processing {product_dir.name}...")
# Remove evaluation key
eval_dir = product_dir / "eval"
if eval_dir.exists():
try:
shutil.rmtree(eval_dir)
print(f"✅ Removed evaluation key for {product_dir.name}")
except Exception as e:
print(f"❌ Error removing eval key: {e}")
# Clean evlsprt from other.xml
options_file = product_dir / "options/other.xml"
if options_file.exists():
try:
self._remove_evlsprt_from_file(options_file)
print(f"✅ Cleaned evlsprt from options for {product_dir.name}")
except Exception as e:
print(f"❌ Error cleaning options: {e}")
# Remove userPrefs
user_prefs = home / ".java/.userPrefs"
if user_prefs.exists():
try:
shutil.rmtree(user_prefs)
print("✅ Removed userPrefs files")
except Exception as e:
print(f"❌ Error removing userPrefs: {e}")
def _remove_evlsprt_from_file(self, file_path):
"""Remove evlsprt entries from XML file"""
try:
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
# Remove lines containing evlsprt
lines = content.splitlines()
cleaned_lines = [line for line in lines if 'evlsprt' not in line]
if len(lines) != len(cleaned_lines):
with open(file_path, 'w', encoding='utf-8') as f:
f.write('\n'.join(cleaned_lines))
except Exception as e:
raise e
def run(self):
"""Main method to detect OS and run appropriate reset"""
print("=" * 60)
print("🚀 JetBrains Trial Reset Tool")
print("=" * 60)
print(f"📊 Detected OS: {platform.system()} {platform.release()}")
print(f"🎯 Target Products: {', '.join(self.jetbrains_products)}")
print()
# Ask for confirmation
response = input("⚠️ This will reset trial periods for all JetBrains IDEs. Continue? (y/N): ")
if response.lower() not in ['y', 'yes']:
print("❌ Operation cancelled")
return
print("\n🔄 Starting reset process...")
if self.system == "windows":
self.reset_windows()
elif self.system == "darwin": # macOS
self.reset_mac()
elif self.system == "linux":
self.reset_linux()
else:
print(f"❌ Unsupported operating system: {self.system}")
return
print("\n" + "=" * 60)
print("✅ JetBrains trial reset completed!")
print("💡 Please restart your JetBrains IDEs for changes to take effect.")
print("=" * 60)
def main():
reset_tool = JetBrainsTrialReset()
reset_tool.run()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment