This repository has been archived by the owner on Apr 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBasicSetup.ps1
183 lines (155 loc) · 6.25 KB
/
BasicSetup.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# Setup.ps1
# Generated files:
# - context-menu-items.txt
# Contains all the paths of the jsons that will be imported.
# They can be single files or a path to a folder with jsons.
#
# - settings.ini:
# It's the configuration, you can change the name
# that the json properties must use and the path to the
# list of json paths (can also be a folder with jsons).
# You can also change the name of "context-menu-items.txt".
#
# - context-menu-items.json:
# This file it's just a template, you can remove it
# and use create the ones you want, and then add their paths
# to "context-menu-items.txt".
#
# - context-menu-items.xml:
# The same as context-menu-items.json but in xml.
#
# The "Source" folder is actually not required, it's only to store the json but you can change it in "context-menu-list.txt"
# If the generated files already exists they won't be overriden.
$sourceFileName = "Source"
$contextMenuListFilename = "context-menu-list.txt"
$defaultContextMenuBasename = "context-menu-items"
# Create settings.ini ------------------------------------------------------------------------------
$settingsDefaultContent = @"
# Names of the context menu properties
PROPERTY_KEY =Key
PROPERTY_NAME =Name
PROPERTY_TYPE =Type
PROPERTY_COMMAND =Command
PROPERTY_OPTIONS =Options
PROPERTY_EXTENDED=Extended
PROPERTY_ICON =Icon
# File with the list of json paths (or folders with json files) to import
CONTEXT_MENU_LIST_PATH=./context-menu-list.txt
# If true shows information about what is happening when importing or removing
CONSOLE_VERBOSE=false
# If true when you execute the import ot remove script it will not close automatically
CONSOLE_NO_EXIT=false
"@
New-Item -Path "settings.ini" -Value $settingsDefaultContent -ErrorAction Ignore
# Create default context-menu-list.txt ------------------------------------------------------------------------------
$contextMenuListFileContent = @"
# You can add all the files you want, with relative or absolute path, also folders with a list of json files
# As you see commets starts with a hash (#)
# This is the deafault json with a context menu
$sourceFileName/$defaultContextMenuJson
"@
New-Item -Path $contextMenuListFilename -Value $contextMenuListFileContent -ErrorAction Ignore
# Create default json template ------------------------------------------------------------------------------
$contextMenuTemplateJsonContent = @"
[
{
"Key" : "file_utils",
"Name" : "File Utils",
"Type" : "File",
"Extended" : true,
"Icon" : "C:/Program Files/internet explorer/images/bing.ico",
"Options" : [
{
"Key" : "read_content",
"Name" : "Read content",
"Icon" : "C:/Program Files/internet explorer/images/bing.ico",
"Command" : "powershell.exe -NoExit -Command Get-Content '%1'"
},
{
"Key" : "remove_content",
"Name" : "Remove content",
"Icon" : "C:/Program Files/internet explorer/images/bing.ico",
"Command" : "powershell.exe -Command Set-Content %1 -Value ''"
},
{
"Key" : "subutils",
"Name" : "SubUtils",
"Icon" : "C:/Program Files/internet explorer/images/bing.ico",
"Options" : [
{
"Key" : "nothing",
"Name" : "Press me! Nothing won't happen.",
"Icon" : "C:/Program Files/internet explorer/images/bing.ico"
}
]
}
]
},
{
"Key" : "get_size_of_all_files",
"Name" : "Get size of folder",
"Type" : "Directory",
"Icon" : "C:/Program Files/internet explorer/images/bing.ico",
"Command" : "powershell.exe -NoExit -Command (Get-ChildItem -File) | ForEach-Object {`$total = 0} { `$total += `$_.Length } { `$total }"
},
{
"Key" : "get_number_of_characters",
"Name" : "Get number of characters",
"Type" : "File",
"Icon" : "C:/Program Files/internet explorer/images/bing.ico",
"Command" : "powershell.exe -NoExit -Command (Get-Content '%1' -Raw).Length"
}
]
"@
New-Item -Path $sourceFileName -ItemType Directory -ErrorAction Ignore
New-Item -Path "$sourceFileName/$defaultContextMenuBasename.json" -Value $contextMenuTemplateJsonContent -ErrorAction Ignore
# Create default xml template ------------------------------------------------------------------------------
$contextMenuTemplateXmlContent = @"
<Root>
<Item
Key="file_utils"
Name="File Utils"
Icon="C:/Program Files/internet explorer/images/bing.ico"
Extended="true"
Type="File"
>
<Item
Key="read_content"
Name="Read content"
Icon="C:/Program Files/internet explorer/images/bing.ico"
Command="powershell.exe -NoExit -Command Get-Content '%1'"
/>
<Item
Key="remove_content"
Name="Remove content"
Icon="C:/Program Files/internet explorer/images/bing.ico"
Command="powershell.exe -Command Set-Content %1 -Value ''"
/>
<Item
Key="subutils"
Name="Get size of folder"
Icon="C:/Program Files/internet explorer/images/bing.ico"
>
<Item
Key="nothing"
Name="Press me! Nothing will happen."
Icon="C:/Program Files/internet explorer/images/bing.ico"
/>
</Item>
</Item>
<Item
Key="get_size_of_all_files"
Name="Get size of folder"
Icon="C:/Program Files/internet explorer/images/bing.ico"
Type="Directory"
Command="powershell.exe -NoExit -Command (Get-ChildItem -File) | ForEach-Object { `$total = 0 } { `$total += `$_.Length } { `$total }"
/>
<Item
Key="get_number_of_characters"
Name="Get number of characters"
Icon="C:/Program Files/internet explorer/images/bing.ico"
Type="File"
Command="powershell.exe -NoExit -Command (Get-Content '%1' -Raw).Length" />
</Root>
"@
New-Item -Path "$sourceFileName/$defaultContextMenuBasename.xml" -Value $contextMenuTemplateXmlContent -ErrorAction Ignore