-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRecreateStartMenu.ps1
More file actions
25 lines (18 loc) · 870 Bytes
/
Copy pathRecreateStartMenu.ps1
File metadata and controls
25 lines (18 loc) · 870 Bytes
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
$sh = New-Object -ComObject WScript.Shell
$startmenupath = 'c:\programdata\Microsoft\windows\Start Menu\Programs'
$templatepath = "$PSScriptRoot\TemplateStartMenu"
$original_elements = gci $startmenupath -Recurse
$new_elements = gci $templatepath -Recurse
$missing = (Compare-Object $new_elements $original_elements | where SideIndicator -eq "<=").Inputobject
$missing | % {
$ElementPath = ($_.Fullname | Split-Path -Parent) -replace [regex]::escape($templatepath),$startmenupath
if ( (get-item $_.FullName) -isnot [System.IO.DirectoryInfo] ) {
if ( test-path $ElementPath -ErrorAction SilentlyContinue) {
$target = $sh.CreateShortcut($_.FullName).TargetPath
if ( test-path $target ) {
write-host "kopiere $($_.Name)"
copy-item $_.FullName $ElementPath
}
}
}
}