Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import tkinter as tk
- from tkinter import ttk
- from tkinter import scrolledtext
- from tkinter import messagebox
- from tkinter import filedialog
- import os
- import platform
- # Create a Tkinter window
- window = tk.Tk()
- window.geometry("1000x680")
- window.configure(bg="#336699")
- window.title("Najeeb CMDER Windows Information PC Management Tool")
- # Function to execute shell commands
- def run_command(command):
- try:
- if command.startswith(('dir ', 'WHERE ', 'ping ', 'wmic ', 'assoc ', 'break ', 'call ', 'cd ', 'chdir ', 'cls ', 'color ', 'copy ', 'date ', 'del ', 'erase ', 'dir ', 'echo ', 'exit ', 'mkdir ', 'mklink ', 'move ', 'rd ', 'rmdir ', 'ren ', 'rename ', 'rmdir ', 'set ', 'setlocal ', 'shift ', 'start ', 'time ', 'title ', 'ver ', 'vol ', 'netsh ')):
- # Use os.system for commands like dir, WHERE, ping, wmic, and cmd commands
- result = os.popen(command).read()
- elif command.startswith('help'):
- # For 'help' command, execute 'cmd /c help' to get help info
- result = subprocess.run(['cmd', '/c', 'help'], capture_output=True, text=True, check=True).stdout.strip()
- else:
- # Use subprocess.run for other commands
- result = subprocess.run(command, capture_output=True, text=True, shell=True, check=True).stdout.strip()
- return result
- except subprocess.CalledProcessError as e:
- messagebox.showerror("Error", f"Command failed: {e.stderr}")
- except FileNotFoundError:
- messagebox.showerror("Error", "Executable file not found. Please check your command.")
- return None
- # Function to display selected command result
- def execute_selected_command():
- selected_command = command_options.get()
- if selected_command:
- output_text.delete(1.0, tk.END) # Clear previous output
- result = run_command(selected_command)
- if result:
- output_text.insert(tk.END, result)
- else:
- output_text.insert(tk.END, "No data available.")
- # Function to execute custom command
- def execute_custom_command():
- custom_command = custom_command_entry.get()
- if custom_command:
- output_text.delete(1.0, tk.END) # Clear previous output
- result = run_command(custom_command)
- if result:
- output_text.insert(tk.END, result)
- else:
- output_text.insert(tk.END, "No data available.")
- else:
- messagebox.showwarning("Warning", "Please enter a command.")
- # Function to clear the output text field
- def clear_output():
- output_text.delete(1.0, tk.END)
- # Function to save displayed result to a text file
- def save_result():
- result = output_text.get(1.0, tk.END)
- if result.strip():
- file_path = filedialog.asksaveasfilename(defaultextension=".txt", filetypes=[("Text files", "*.txt")])
- if file_path:
- with open(file_path, "w") as file:
- file.write(result)
- messagebox.showinfo("Success", "Result saved successfully.")
- else:
- messagebox.showwarning("Warning", "No data to save.")
- # Function to show help.txt
- def show_help():
- # Save help information to Help.txt file
- #run_command('Help >> Help.txt')
- # Read help information from file
- with open("Help.txt", "r") as file:
- help_text = file.read()
- if help_text:
- output_text.delete(1.0, tk.END)
- output_text.insert(tk.END, help_text)
- else:
- output_text.delete(1.0, tk.END)
- output_text.insert(tk.END, "No help available.")
- # Function to delete help.txt
- def delete_help_file():
- try:
- os.remove("Help.txt")
- messagebox.showinfo("Success", "Help.txt deleted successfully.")
- except FileNotFoundError:
- messagebox.showwarning("Warning", "Help.txt not found.")
- # Function to open file with default program
- def open_with_default_program(file_path):
- if platform.system() == "Windows":
- os.startfile(file_path)
- elif platform.system() == "Darwin":
- subprocess.call(["open", file_path])
- else:
- subprocess.call(["xdg-open", file_path])
- # Function to handle double-click event on output text
- def on_double_click(event):
- index = output_text.index("@%s,%s" % (event.x, event.y))
- line, column = map(int, index.split('.'))
- word = output_text.get('%d.0' % line, '%d.end' % line)
- if os.path.isfile(word.strip()):
- open_with_default_program(word.strip())
- # Function to search for a query in the output text
- def search_query():
- query = search_entry.get()
- if query:
- search_text(output_text, query)
- else:
- messagebox.showwarning("Warning", "Please enter a search query.")
- # Function to search for a query within a text widget
- def search_text(text_widget, query):
- text_widget.tag_remove('highlight', '1.0', tk.END)
- count = tk.IntVar()
- idx = '1.0'
- while True:
- idx = text_widget.search(query, idx, nocase=1, stopindex=tk.END, count=count)
- if not idx:
- break
- line_start = text_widget.index('%s linestart' % idx)
- line_end = text_widget.index('%s lineend' % idx)
- text_widget.tag_add('highlight', line_start, line_end)
- idx = line_end
- text_widget.tag_config('highlight', background='yellow')
- # Dropdown list of commands
- commands = [
- "--[NAJEEB PC TOOLS]--",
- "--[HELP= -H ; --H ; -Help ; --Help ; /? ; ?]--",
- "Everything.exe -search Najeeb",
- "ES.exe -a jpg",
- "WHERE /R D:\ *.mp4",
- "TYPE C:\CMDER\BOOKS\COMMANDS.txt",
- "START C:/CMDER/BOOK.py",
- "START C:\CMDER\TOOLS\LIST.pyw",
- "START C:\CMDER\TOOLS\RENAME-EXT.pyw",
- "START C:\CMDER\TOOLS\ALL-RADIOS.pyw",
- "START C:\CMDER\TOOLS\TOOL.ahk",
- "START C:\CMDER\SOFT\SOFT.ahk",
- "START C:\CMDER\APP\APPS.ahk",
- "START C:\CMDER\HOME.ahk",
- "START C:\CMDER\TOOLS.ahk",
- "START C:\CMDER\COMMANDER.ahk",
- "START C:\CMDER\CMDR.ahk",
- "START C:\CMDER\CMD.ahk",
- "START C:\CMDER\FFMPEG.ahk",
- "START C:\CMDER\AHK.ahk",
- "--[NAJEEB PC INFORMATION]--",
- "systeminfo",
- "msinfo32",
- "compmgmt.msc",
- "diskmgmt.msc",
- "devmgmt.msc",
- "Control Panel",
- "START shell:AppData",
- "START shell:Startup",
- "START shell:ProgramFiles",
- "START C:/Users/Najeeb/AppData/Local/Temp",
- "START C:\Windows\Prefetch",
- "START C:\Windows\Temp",
- "TZUTIL /L",
- "TZUTIL /G",
- 'TZUTIL /S "Pakistan Standard Time"',
- "tasklist",
- "whoami",
- "whoami /priv",
- "cmdkey /list",
- 'dir "C:\\Program Files"',
- 'dir /S /B /A "C:\\"',
- 'dir /S /B /A "D:\\"',
- 'dir /S /B /A "E:\\"',
- 'dir /S /B /A "F:\\"',
- 'dir /S /B /A "G:\\"',
- 'dir /S /B /A "I:\\"',
- 'dir /S /B /A "Z:\\"',
- "--[NIRCMD Commands]--",
- "nircmd.exe emptybin & Exit",
- "nircmd.exe mutesysvolume 1",
- "nircmd.exe mutesysvolume 0",
- 'nircmd.exe loop 10 60000 savescreenshot "~$folder.desktop$\P~$loopcount$.png" & Exit',
- "--[CMD HELP COMMANDS]--",
- "Help >> Help.txt",
- "WHERE /?",
- "wget --help",
- "FFMPEG -h",
- "youtube-dl -h",
- "magick -help",
- "wget --help",
- "DOSKEY /?",
- "netsh /?",
- "wmic /?",
- ]
- # Create dropdown list
- command_options = ttk.Combobox(window, values=commands, state="readonly", width=74, font=("Arial", 12))
- command_options.grid(row=1, column=0, padx=10, pady=(10, 5))
- # Entry field for custom command
- custom_command_entry = tk.Entry(window, width=74, font=("Arial", 12))
- custom_command_entry.grid(row=2, column=0, padx=10, pady=5)
- # Button to execute selected command
- execute_button = tk.Button(window, text="Execute Selected Command", command=execute_selected_command, fg="White", bg="Blue")
- execute_button.grid(row=1, column=1, padx=10, pady=(10, 5), sticky="w")
- # Button to execute custom command
- execute_custom_button = tk.Button(window, text="Execute Custom Command", command=execute_custom_command, fg="White", bg="Blue")
- execute_custom_button.grid(row=2, column=1, padx=10, pady=5, sticky="w")
- # Button to clear output
- clear_button = tk.Button(window, text="Clear Text Field", command=clear_output, fg="white", bg="Red")
- clear_button.grid(row=1, column=2, padx=10, pady=(10, 5), sticky="w")
- # Button to save result
- save_button = tk.Button(window, text="Save Result", command=save_result, fg="white", bg="Green")
- save_button.grid(row=1, column=3, padx=10, pady=(10, 5), sticky="w")
- # Button to show help.txt
- help_button = tk.Button(window, text="Show Help", command=show_help, fg="black", bg="yellow")
- help_button.grid(row=1, column=4, padx=10, pady=(10, 5), sticky="w")
- # Button to delete help.txt
- delete_help_button = tk.Button(window, text="Delete Help", command=delete_help_file, fg="black", bg="orange")
- delete_help_button.grid(row=2, column=4, padx=10, pady=5, sticky="w")
- # Search entry field
- search_entry = tk.Entry(window, width=74, font=("Arial", 12))
- search_entry.grid(row=3, column=0, padx=10, pady=5)
- # Button to perform search
- search_button = tk.Button(window, text="Search Command", command=search_query, fg="black", bg="lightblue")
- search_button.grid(row=3, column=1, padx=10, pady=5, sticky="w")
- # Text field to display output
- output_text = scrolledtext.ScrolledText(window, width=107, height=27, wrap=tk.WORD, font=("Arial", 12))
- output_text.grid(row=4, column=0, columnspan=5, padx=10, pady=10, sticky="nsew")
- # Label for the heading
- heading_label = tk.Label(window, text="NAJEEB ALL PC INFORMATION", font=("Arial", 24, "bold"), bg="#336699", fg="white")
- heading_label.grid(row=0, column=0, columnspan=5, pady=(5, 10))
- # Bind double-click event to output text field
- output_text.bind("<Double-Button-1>", on_double_click)
- # Configure grid weights to make the text field expandable
- window.grid_columnconfigure(0, weight=1)
- window.grid_rowconfigure(3, weight=1)
- # Run the Tkinter event loop
- window.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement