-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keep Windows networking tidy. At boot a Powershell script will run that clears out old network profile names automatically created at previous system reboots. A regist change disables the "Do you want your PC to be discoverable" nag screen after eachc reboot
- Loading branch information
Showing
2 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
Windows Registry Editor Version 5.00 | ||
|
||
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Terminal Server\TSAppAllowList] | ||
; Disable RemoteApp allowlist so all applications can be used in a Remote Desktop session | ||
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Terminal Server\TSAppAllowList] | ||
"fDisabledAllowList"=dword:00000001 | ||
|
||
; Allow unlisted programs to be run in Remote Desktop sessions | ||
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services] | ||
"fAllowUnlistedRemotePrograms"=dword:00000001 | ||
|
||
; Disable automatic administrator logon at startup | ||
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon] | ||
"AutoAdminLogon"="0" | ||
|
||
; Disable "Do you want your PC to be discoverable" prompt after each host system reboot | ||
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\NewNetworkWindowOff] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,54 @@ | ||
@echo off | ||
|
||
REG IMPORT C:\OEM\RDPApps.reg | ||
|
||
:: Write the Powershell network profile cleanup script | ||
( | ||
echo # Get the current network profile name | ||
echo $currentProfile = ^(Get-NetConnectionProfile^).Name | ||
echo. | ||
echo # Get all profiles from the registry | ||
echo $profilesKey = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles" | ||
echo $profiles = Get-ChildItem -Path $profilesKey | ||
echo. | ||
echo foreach ^($profile in $profiles^) { | ||
echo $profilePath = "$profilesKey\$($profile.PSChildName)" | ||
echo $profileName = ^(Get-ItemProperty -Path $profilePath^).ProfileName | ||
echo. | ||
echo # Remove profiles that don't match the current one | ||
echo if ^($profileName -ne $currentProfile^) { | ||
echo Remove-Item -Path $profilePath -Recurse | ||
echo Write-Host "Deleted profile: $profileName" | ||
echo } | ||
echo } | ||
echo. | ||
echo # Change the current profile name to "WinApps" | ||
echo $profiles = Get-ChildItem -Path $profilesKey | ||
echo foreach ^($profile in $profiles^) { | ||
echo $profilePath = "$profilesKey\$($profile.PSChildName)" | ||
echo $profileName = ^(Get-ItemProperty -Path $profilePath^).ProfileName | ||
echo. | ||
echo if ^($profileName -eq $currentProfile^) { | ||
echo # Update the profile name | ||
echo Set-ItemProperty -Path $profilePath -Name "ProfileName" -Value "WinApps" | ||
echo Write-Host "Renamed profile to: WinApps" | ||
echo } | ||
echo } | ||
) > C:\Windows\NetProfileCleanup.ps1 | ||
|
||
:: Create network profile cleanup scheduled task | ||
set "taskname=NetworkProfileCleanup" | ||
set "command=powershell.exe -ExecutionPolicy Bypass -File "C:\Windows\NetProfileCleanup.ps1^"" | ||
|
||
schtasks /query /tn "%taskname%" >nul 2>&1 | ||
if %ERRORLEVEL% equ 0 ( | ||
echo Task "%taskname%" already exists, deleting it first... | ||
schtasks /delete /tn "%taskname%" /f | ||
) | ||
|
||
schtasks /create /tn "%taskname%" /tr "%command%" /sc onstart /ru "SYSTEM" /rl HIGHEST /f | ||
if %ERRORLEVEL% equ 0 ( | ||
echo Scheduled task "%taskname%" created successfully. | ||
) else ( | ||
echo Failed to create scheduled task. | ||
) |