PBA tweaks: Windows
This commit is contained in:
parent
80c8a42bd0
commit
6b4e90e6d0
|
@ -23,10 +23,6 @@ def get_commands_to_hide_folders():
|
||||||
return linux_cmds, windows_cmds
|
return linux_cmds, windows_cmds
|
||||||
|
|
||||||
|
|
||||||
def get_winAPI_to_hide_files():
|
|
||||||
get_winAPI_to_hide_files()
|
|
||||||
|
|
||||||
|
|
||||||
def cleanup_hidden_files(is_windows=is_windows_os()):
|
def cleanup_hidden_files(is_windows=is_windows_os()):
|
||||||
subprocess.run(get_windows_commands_to_delete() if is_windows
|
subprocess.run(get_windows_commands_to_delete() if is_windows
|
||||||
else get_linux_commands_to_delete())
|
else get_linux_commands_to_delete())
|
||||||
|
|
|
@ -1,30 +1,40 @@
|
||||||
HIDDEN_FILE = 'C:\\monkey-hidden-file'
|
HIDDEN_FILE = "%temp%\\monkey-hidden-file"
|
||||||
HIDDEN_FILE_WINAPI = 'C:\\monkey-hidden-file-winAPI'
|
HIDDEN_FILE_WINAPI = "%temp%\\monkey-hidden-file-winAPI"
|
||||||
HIDDEN_FOLDER = 'C:\\monkey-hidden-folder'
|
HIDDEN_FOLDER = "%temp%\\monkey-hidden-folder"
|
||||||
|
|
||||||
|
|
||||||
def get_windows_commands_to_hide_files():
|
def get_windows_commands_to_hide_files():
|
||||||
return [
|
return [
|
||||||
'type NUL >', # create empty file
|
'echo',
|
||||||
|
'Successfully created hidden file: {}'.format(HIDDEN_FILE), # create empty file
|
||||||
|
'>',
|
||||||
HIDDEN_FILE,
|
HIDDEN_FILE,
|
||||||
'&& attrib', # change file attributes
|
'&&',
|
||||||
|
'attrib', # change file attributes
|
||||||
'+h', # make hidden
|
'+h', # make hidden
|
||||||
HIDDEN_FILE,
|
HIDDEN_FILE,
|
||||||
'echo Successfully created hidden file: {0} > {0}'.format(HIDDEN_FILE),
|
'&&',
|
||||||
'&& type {}'.format(HIDDEN_FILE)
|
'type',
|
||||||
|
HIDDEN_FILE
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def get_windows_commands_to_hide_folders():
|
def get_windows_commands_to_hide_folders():
|
||||||
return [
|
return [
|
||||||
'mkdir', # make directory
|
'mkdir',
|
||||||
HIDDEN_FOLDER,
|
HIDDEN_FOLDER, # make directory
|
||||||
'&& attrib', # change file attributes
|
'&&',
|
||||||
'+h', # make hidden
|
'attrib',
|
||||||
HIDDEN_FOLDER,
|
'+h',
|
||||||
'&& echo Successfully created hidden folder: {} >'.format(HIDDEN_FOLDER),
|
HIDDEN_FOLDER, # change file attributes
|
||||||
|
'&&',
|
||||||
|
'echo',
|
||||||
|
'Successfully created hidden folder: {}'.format(HIDDEN_FOLDER),
|
||||||
|
'>',
|
||||||
'{}\\{}'.format(HIDDEN_FOLDER, 'some-file'),
|
'{}\\{}'.format(HIDDEN_FOLDER, 'some-file'),
|
||||||
'&& type {}'.format(HIDDEN_FOLDER, 'some-file')
|
'&&',
|
||||||
|
'type',
|
||||||
|
'{}\\{}'.format(HIDDEN_FOLDER, 'some-file')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,11 +47,11 @@ def get_winAPI_to_hide_files():
|
||||||
|
|
||||||
hiddenFile = win32file.CreateFile(HIDDEN_FILE_WINAPI,
|
hiddenFile = win32file.CreateFile(HIDDEN_FILE_WINAPI,
|
||||||
fileAccess,
|
fileAccess,
|
||||||
0,
|
0, # sharing mode: 0 => can't be shared
|
||||||
None,
|
None, # security attributes
|
||||||
fileCreation,
|
fileCreation,
|
||||||
fileFlags,
|
fileFlags,
|
||||||
0)
|
0) # template file
|
||||||
|
|
||||||
return "Succesfully created hidden file: {}".format(HIDDEN_FILE_WINAPI), True
|
return "Succesfully created hidden file: {}".format(HIDDEN_FILE_WINAPI), True
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
@ -51,9 +61,11 @@ def get_winAPI_to_hide_files():
|
||||||
def get_windows_commands_to_delete():
|
def get_windows_commands_to_delete():
|
||||||
return [
|
return [
|
||||||
'del', # delete file
|
'del', # delete file
|
||||||
'/f', # force delete
|
'-Force', # force delete
|
||||||
HIDDEN_FILE,
|
HIDDEN_FILE,
|
||||||
HIDDEN_FILE_WINAPI,
|
HIDDEN_FILE_WINAPI,
|
||||||
'&& rmdir', # delete folder
|
'&&',
|
||||||
|
'rmdir', # delete folder
|
||||||
|
'-Force',
|
||||||
HIDDEN_FOLDER
|
HIDDEN_FOLDER
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue