Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion malboxes/malboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,11 @@ def registry(profile_name, reg_mod, fd):
Adds a registry key modification to a profile with PowerShell commands.
"""
if reg_mod["modtype"] == "add":
# Creates registry path if it doesn't exist
reg_key_line = 'if ( -not (Test-Path "{0}") ){{New-Item "{0}" -Force}}\r\n' \
.format(reg_mod["key"])
fd.write(reg_key_line)

command = "New-ItemProperty"
line = '{} -Path "{}" -Name "{}" -Value "{}" -PropertyType "{}"\r\n' \
.format(command, reg_mod["key"], reg_mod["name"], reg_mod["value"],
Expand Down Expand Up @@ -560,7 +565,7 @@ def document(profile_name, modtype, docpath, fd):
line = '{0} -Path "{1}"\r\n'.format(command, docpath)
print("Removing file: {}".format(docpath))
else:
print("Directory modification type invalid.")
print("Document modification type invalid.")
print("Valid ones are: add, delete.")

fd.write(line)
Expand Down