Skip to content

Commit

Permalink
Merge pull request #84 from snakems/registry_mod_fix
Browse files Browse the repository at this point in the history
Improve registry mod
  • Loading branch information
obilodeau committed Sep 27, 2017
2 parents 2200c08 + e9b4177 commit 029d76f
Showing 1 changed file with 6 additions and 1 deletion.
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

0 comments on commit 029d76f

Please sign in to comment.