-
Notifications
You must be signed in to change notification settings - Fork 0
/
folders-icons
57 lines (48 loc) · 1.79 KB
/
folders-icons
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
# Definition of folder paths and desktop.ini contents
$FolderPath_1 = "C:\Users\%USERPROFILE%\test1"
$FolderPath_2 = "C:\Users\%USERPROFILE%\test2"
$FolderPath_3 = "C:\Users\%USERPROFILE%\test3"
# ...
# Definition of changes in desktop.ini for each folder
$INI_1 = @"
[.ShellClassInfo]
IconResource=C:\WINDOWS\System32\SHELL32.dll,314
"@
$INI_2 = @"
[.ShellClassInfo]
IconResource=C:\WINDOWS\System32\SHELL32.dll,315
"@
$INI_3 = @"
[.ShellClassInfo]
IconResource=C:\WINDOWS\System32\SHELL32.dll,316
"@
# ...
# Function to modify desktop.ini
function Set-DesktopINI {
param (
[string]$TargetDirectory,
[string]$INIContent
)
# Check if desktop.ini file already exists
if (Test-Path "$TargetDirectory\desktop.ini") {
# Read the content of the existing desktop.ini file
$existingContent = Get-Content "$TargetDirectory\desktop.ini" -Raw
# Check if existing content is different from new content
if ($existingContent -ne $INIContent) {
# If existing content is different from new content, replace the content
Set-Content "$TargetDirectory\desktop.ini" -Value $INIContent
}
} else {
# If desktop.ini file doesn't exist, create the content
Add-Content "$TargetDirectory\desktop.ini" -Value $INIContent
# Set attributes for $DesktopIni
(Get-Item "$TargetDirectory\desktop.ini" -Force).Attributes = 'Hidden, System, Archive'
# Finally, set folder attributes
(Get-Item $TargetDirectory -Force).Attributes = 'ReadOnly, Directory'
}
}
# Modify desktop.ini for each folder
Set-DesktopINI -TargetDirectory $FolderPath_1 -INIContent $INI_1
Set-DesktopINI -TargetDirectory $FolderPath_2 -INIContent $INI_2
Set-DesktopINI -TargetDirectory $FolderPath_3 -INIContent $INI_3
# ...