-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathox-os-windows.ps1
115 lines (96 loc) · 3.42 KB
/
ox-os-windows.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
##########################################################
# config
##########################################################
function open { explorer $args }
##########################################################
# main
##########################################################
function clean {
param ( $obj )
Switch ( $obj ) {
scoop { rm -r $env:SCOOP\cache }
Default { Clear-RecycleBin -Confirm }
}
}
function hide {
$file = Get-Item $args[0] -Force
$file.attributes = 'Hidden'
}
function shutdown { Stop-Computer -Force }
function restart { Restart-Computer -Force }
function which { (Get-Command $args[0]).Source }
##########################################################
# winget
##########################################################
# system files
$Global:OX_ELEMENT.w = "$env:LOCALAPPDATA\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json"
# backup files
if ([string]::IsNullOrEmpty("$env:OX_BACKUP\win")) {
mkdir "$env:OX_BACKUP\win"
}
$Global:OX_OXIDE.bkw = "$env:OX_BACKUP\win\winget.jsonc"
$Global:OX_OXIDE.bkwx = "$env:OX_BACKUP\win\Wingetfile.json"
function up_winget {
echo "Update Scoop by $($Global:OX_OXIDE.bkwx)"
winget import -i $Global:OX_OXIDE.bkwx
}
function back_winget {
echo "Backup Scoop by $($Global:OX_OXIDE.bkwx)"
winget export -o $Global:OX_OXIDE.bkwx
}
function wis { winget install $args }
function wus { winget uninstall $args }
function wls { winget list $args }
function wst { winget list --upgrade-available }
function wif { winget show $args }
function wifs { winget --info }
function wcl { rm -rfv "$HOME/AppData/Local/Temp/WinGet" }
function wsc { winget search $args }
function wup {
if (-not $args) { winget upgrade * }
else { winget upgrade $args }
}
function wcf { winget settings }
# extension
function wxa { param ( $repo ) winget source add $repo }
function wxrm { param ( $repo ) winget source remove $repo }
function wxls { param ( $repo ) winget source list }
function reset_msstore {
# Turn on TLS 1.0, TLS 1.1, TLS 1.2, 和 TLS 1.3...
$secureProtocolsPath = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings'
$secureProtocolsValue = 0x2AA0
# Set SecureProtocols (the following line returns msg)
New-ItemProperty -Path $secureProtocolsPath -Name 'SecureProtocols' -Value $secureProtocolsValue -PropertyType DWord -Force -ErrorAction Stop
# Stop IE proxy server
Set-ItemProperty -Path $secureProtocolsPath -Name 'ProxyEnable' -Value 0 -Force -ErrorAction Stop
}
##########################################################
# wsl
##########################################################
function wslis {
if (-not $args) { wsl --install }
else { wsl --install -d $args }
}
function wslus { param ( $dist ) wslconfig /u $dist }
function wslls { wsl.exe --list -v }
function wsllsa { wsl.exe --list --online }
function wslset {
param ( $ver )
Switch ($ver) {
{ $ver -eq 2 } { 1 }
Default { 2 }
}
wsl.exe --set-version $ver
}
function wslcl {
param ( $dist )
Switch ( $dist ) {
kali { $file = "$env:LOCALAPPDATA\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\LocalState\ext4.vhdx" }
Default { $file = "$env:LOCALAPPDATA\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\ext4.vhdx" }
}
diskpart
Select-Object vdisk file=$file
attach vdisk readonly
compact vdisk
detach vdisk
}