# Workaround and Command ### Extract MSU file ``` expand -f:* "C:\%InstallFile%.msu" %TEMP% ``` For example: ``` expand -f:* "C:\Temp\Windows6.1-KB2896256-x64.msu" C:\TEMP ``` ### Install MSU via DISM ``` dism.exe /online /add-package /packagepath:"." /quiet /norestart /logpath:"/path/Logs.txt" ``` For example: ``` dism.exe /online /add-package /packagepath:"C:\Temp\Windows6.1-KB2896256-x64.cab" /quiet /norestart /logpath:"C:\Logs\Install_hotfix_Windows6.1-KB2896256-x64.log" ``` ### Get a program's installation path using Powershell ``` Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | % { Get-ItemProperty $_.PsPath } | Select DisplayName,InstallLocation ``` ### Use KB947821 to repair Windows 7 Sp1 upgrade ``` File Extension | Subdirectory of %WINDIR%\Temp\CheckSUR\ (create if needed) -------------- | ------- cat | servicing\Packages\ mum | servicing\Packages\ manifest | winsxs\Manifests\ msu (alternate)| Packages\ ``` ### Convert Wua History ResultCode ``` # Convert Wua History ResultCode to a Name # 0, and 5 are not used for history # See https://msdn.microsoft.com/en-us/library/windows/desktop/aa387095(v=vs.85).aspx function Convert-WuaResultCodeToName { param( [Parameter(Mandatory=$true)] [int] $ResultCode ) $Result = $ResultCode switch($ResultCode) { 2 { $Result = "Succeeded" } 3 { $Result = "Succeeded With Errors" } 4 { $Result = "Failed" } } return $Result } function Get-WuaHistory { # Get a WUA Session $session = (New-Object -ComObject 'Microsoft.Update.Session') # Query the latest 1000 History starting with the first recordp $history = $session.QueryHistory("",0,50) | ForEach-Object { $Result = Convert-WuaResultCodeToName -ResultCode $_.ResultCode # Make the properties hidden in com properties visible. $_ | Add-Member -MemberType NoteProperty -Value $Result -Name Result $Product = $_.Categories | Where-Object {$_.Type -eq 'Product'} | Select-Object -First 1 -ExpandProperty Name $_ | Add-Member -MemberType NoteProperty -Value $_.UpdateIdentity.UpdateId -Name UpdateId $_ | Add-Member -MemberType NoteProperty -Value $_.UpdateIdentity.RevisionNumber -Name RevisionNumber $_ | Add-Member -MemberType NoteProperty -Value $Product -Name Product -PassThru Write-Output $_ } #Remove null records and only return the fields we want $history | Where-Object {![String]::IsNullOrWhiteSpace($_.title)} | Select-Object Result, Date, Title, SupportUrl, Product, UpdateId, RevisionNumber } ``` ``` # Get all the update History, formatted as a table Get-WuaHistory | Format-Table ``` ### Update-Help through Authenticating proxy ``` $webclient = New-Object System.Net.WebClient $creds = Get-Credential #Prompts for credentials $webclient.Proxy.Credentials = $creds Update-Help ``` ### Fix PRINTERS right ``` icacls C:\Windows\System32\spool\PRINTERS /grant USERS:(OI)(CI)F /T ``` ### [DISM Capture Image](https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/dism-image-management-command-line-options-s14#capture-image) ``` Dism /Capture-Image /ImageFile:<path_to_image_file> /CaptureDir:<source_directory> /Name:<image_name> {[/Compress:{max|fast|none}]} [/CheckIntegrity] [/Verify] ``` ### ImageX ``` imagex /capture C: g:\image.wim “Windows 7” /compress fast /verify ``` ### Add My Computer Icon to all Desktop ``` [HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel] "{20D04FE0-3AEA-1069-A2D8-08002B30309D}"=dword:00000000 [HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu] "{20D04FE0-3AEA-1069-A2D8-08002B30309D}"=dword:00000000 ``` ### Shared Setting ``` HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Shares ``` ### Remove Xbox and Game DVR ``` sc delete XblAuthManager sc delete XblGameSave sc delete XboxNetApiSvc sc delete XboxGipSvc reg delete "HKLM\SYSTEM\CurrentControlSet\Services\xbgm" /f schtasks /Change /TN "Microsoft\XblGameSave\XblGameSaveTask" /disable schtasks /Change /TN "Microsoft\XblGameSave\XblGameSaveTaskLogon" /disable reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\GameDVR" /v AllowGameDVR /t REG_DWORD /d 0 /f ``` ### Remove Windows Defender ``` reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" /v SmartScreenEnabled /t REG_SZ /d "Off" /f reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\AppHost" /v "EnableWebContentEvaluation" /t REG_DWORD /d "0" /f reg add "HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\PhishingFilter" /v "EnabledV9" /t REG_DWORD /d "0" /f reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender" /v DisableAntiSpyware /t REG_DWORD /d 1 /f reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" /v SpyNetReporting /t REG_DWORD /d 0 /f reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" /v SubmitSamplesConsent /t REG_DWORD /d 2 /f reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" /v DontReportInfectionInformation /t REG_DWORD /d 1 /f reg delete "HKLM\SYSTEM\CurrentControlSet\Services\Sense" /f reg delete "HKLM\SYSTEM\CurrentControlSet\Services\SecurityHealthService" /f reg add "HKLM\SOFTWARE\Policies\Microsoft\MRT" /v "DontReportInfectionInformation" /t REG_DWORD /d 1 /f reg add "HKLM\SOFTWARE\Policies\Microsoft\MRT" /v "DontOfferThroughWUAU" /t REG_DWORD /d 1 /f reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "SecurityHealth" /f reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run" /v "SecurityHealth" /f reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\SecHealthUI.exe" /v Debugger /t REG_SZ /d "%windir%\System32\taskkill.exe" /f ``` ### Disable IPv6 via Powershell ``` Disable-NetAdapterBinding -Name "*" -ComponentID ms_tcpip6 -PassThru ``` ### Offline install Net framework 3.5 in Windows 10 Mount Windows 10 Install Source to Windows 10 ``` Dism /online /enable-feature /featurename:NetFX3 /All /Source:D:\sources\sxs /LimitAccess ``` ### Enable or disable USB drives in Windows 10 via Registry If you are comfortable making changes to Windows Registry, you can enable or disable USB drives in Windows 10 by manually editing the Registry. Here is how to do that. Step 1: Open the Registry Editor Step 2: Navigate to the following key: ``` HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR ``` Step 3: Now, on the right-side, double-click on Start DWORD value and change its value to 4 to disable USB drives and USB storage devices on your Windows 10 PC. Change the Start DWORD value back to 3 to enable USB drives and storage devices on your PC. ### UsoClient On using Sysinternal's Strings on UsoClient.exe, I found that there are more switches which can be used - **StartScan** Used To Start Scan **StartDownload** Used to Start Download of Patches **StartInstall** Used to Install Downloaded Patches **RefreshSettings** Refresh Settings if any changes were made **StartInteractiveScan** May ask for user input and/or open dialogues to show progress or report errors **RestartDevice** Restart device to finish installation of updates **ScanInstallWait** Combined Scan Download Install **ResumeUpdate** Resume Update Installation On Boot ### Enable Num Lock On ``` HKEY_USERS\.DEFAULT\Control Panel\Keyboard\InitialKeyboardIndicators REG_SZ: 2147483648 HKEY_CURRENT_USER\Control Panel\Keyboard\InitialKeyboardIndicators REG_SZ: 2147483648 ``` ### Executing SFC /SCANNOW From Outside of Windows When running sfc /scannow from outside of Windows, like from the Command Prompt available when you boot from your Windows installation disc or flash drive, or from your System Repair Disc or Recovery Drive, you'll have to tell the sfc command exactly where Windows exists. Here's an example: ``` sfc /scannow /offbootdir=d:\ /offwindir=d:\windows ``` The /offbootdir= option specifies the drive letter, while the /offwindir= option specifies the Windows path, again including the drive letter. ### CredSSP Fix for After Update KB4103718 or KB4103718 ``` [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters] "AllowEncryptionOracle"=dword:00000002 ``` ### Get Bitlocker Recovery Key ``` manage-bde -protectors C: -get -t recoverypassword ``` ### Check Officescan Version ``` "C:\Program Files (x86)\Trend Micro\OfficeScan Client\PccNTMon.exe" -v ``` ### Open Key Manager ``` RunDll32.exe keymgr.dll,KRShowKeyMgr ``` ### Open Add and Remove ``` RunDll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,2 ``` ### Delete IE Password ``` RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32 ``` ### Check Windows Version with GUI ``` RunDll32.exe SHELL32.DLL,ShellAboutW ``` ### Demo Path ```batch== @echo off cls @echo Full path and filename: %~f0 @echo Drive: %~d0 @echo Path: %~p0 @echo Drive and path: %~dp0 @echo Filename without extension: %~n0 @echo Filename with extension: %~nx0 @echo Extension: %~x0 @echo Filename as given on command line: %0 @echo Filename as given on command line minus quotes: %~0 @REM Build from parts @SETLOCAL @SET drv=%~d0 @SET pth=%~p0 @SET fpath=%~dp0 @SET fname=%~n0 @SET ext=%~x0 @echo Simply Constructed name: %fpath%%fname%%ext% @echo Fully Constructed name: %drv%%pth%%fname%%ext% @ENDLOCAL pause ``` ### Auto Install MSU in folder ```batch== @echo off cls title %computername% - %date% - %~n0 SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION FOR /R "%~dp0" %%A IN (*Windows6.1-KB*.MSU) DO ( CALL :SUB %%~nA ECHO= Installing KB!KB_NUM! >NUL net stop wuauserv WUSA "%%A" /quiet /norestart) ECHO= == Press any key to close the Window == >NUL PAUSE GOTO :EOF :SUB SET "KB_NUM=%*" FOR /F "DELIMS=-" %%B IN ("%KB_NUM:*-KB=%") DO SET "KB_NUM=%%B" ``` ### Force change Pagefile Size Disable the automatic pagefile and Set pagefile for C Drive ```batch== wmic computersystem where name="%computername%" set AutomaticManagedPagefile=False wmic pagefileset set name="c:\\\pagefile.sys",InitialSize=1024,MaximumSize=2048 ``` ### Change Windows Keyboard Layout for current user ```reg=== [HKEY_CURRENT_USER\Keyboard Layout\Preload] "2"="00000404" "1"="00003c09" ``` | Value | Meaning | | :--- | :--- | | 00000404 | English | | 00003c09 | Quick | ### Get Windows Activation remotely with PowerShell ```batch== Get-WmiObject -Class SoftwareLicensingProduct -Filter "PartialProductKey LIKE '%'" -ComputerName Computer1 ``` ### Anti SEO ```html= <meta name="ia_archiver" content="noindex"> <meta name="robots" content="noindex, nofollow, nosnippet, noarchive, notranslate, noimageindex"> <meta name="googlebot" content="noindex, nofollow, nosnippet, noarchive, notranslate, noimageindex"> <meta name="AdsBot-Google" content="noindex, nofollow, nosnippet, noarchive, notranslate, noimageindex" /> ``` | 指令 | 意義 | | :--- | :--- | | `noindex` | 不在搜尋結果中顯示這個網頁,也不要在搜尋結果中顯示「快取」連結。 | | `nofollow` | 不跟蹤這個網頁上的連結 | | `noarchive` | 不在搜尋結果中顯示「快取」連結。 | | `nosnippet` | 不在搜尋結果中顯示這個網頁的程式碼片段 | | `notranslate` | 不在搜尋結果中提供這個網頁的翻譯。 | | `noimageindex` | 不為這個網頁上的圖片建立索引。 | https://developers.google.com/search/reference/robots_meta_tag?hl=zh-tw ### Lenovo 進入BIOS | **ThinkPad model** | Action | | --- | --- | | G40, G41, R40, R40e, R50/e/p, R51, R52, T40/p, T41/p, T42/p, T43/p, X40, X41, X41 Tablet | Press the blue **Access IBM** button when the message "To interrupt normal startup, press the blue Access IBM button" is displayed to enter the ThinkVantage Productivity Center, then select **Start setup utility** to open the BIOS Setup Utility. | | R51e, R60/e/i, R61/e/i, T60/p, T61/p, X60/s, X61, X61 Tablet, Z60m/t, Z61e/m/p/t, Reserve Edition | Press the blue **ThinkVantage** button when the message "To interrupt normal startup, press the blue ThinkVantage button " is displayed to enter the ThinkVantage Productivity Center, then select **Start setup utility** to open the BIOS Setup Utility. | 240 series, 390 series, 570 series, i Series 1200, i Series 1300, i Series 1400, i Series 1500, i Series 172x, A20, A21, A22, A30, A31, R30, R31, R32, S30, S31, T20, T21, T22, T23, T30, X20, X21, X22, X23, X24, X30, X31 TransNote | Pressing **F1** during startup when the ThinkPad logo is displayed. | | **ThinkPad model** | Action | | --- | --- | | 310, 315, 310E/ED, 315ED | BIOS Utility is entered by holding **F2** while the ThinkPad logo is displayed after power on. | | 365C/CS, 365CD/CSD, 365E/ED | Enter setup by pressing **CTRL+Alt+F11** from a DOS prompt (you must be in DOS mode, not a DOS session under Windows). | | 365X/XD | With the unit powered off, hold the **F1** key and power the unit on. Keep F1 held down until Easy setup appears | | 360, 355 series, 380, 385 series, 560 series, 600 series, 701C/CS, 75x series, 76x series, 770 series | With the unit powered off, hold the **F1** key and power the unit on. Keep F1 held down until Easy setup appears. **Note**: On the TP 701, you can also access the Configuration area on BIOS by pressing the**Fn+F1** keys. | | 500, 510 | Enter setup by pressing **CTRL+Alt+F3** from a DOS prompt (you must be in DOS mode, not a DOS session under Windows). | | 700/C, 720/C | Pressing **CTRL+ALT+INS** when the cursor moves over to the upper right hand side of the screen right after the memory count. | | 710T, 730T | Hold the suspend/resume switch while powering on the computer. | ### 語言列消失了沒辦法打中文解決方法 > 純屬自己筆記,如有侵權請告知 語言列消失了沒辦法打中文解決方法: 1.點選開始功能表,在「開始搜尋」的輸入框中輸入"regedit"並執行 2.找到 `HKEY\_CURRENT\_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run` 3.此行是在開機的時候應該自動執行的程式清單,右邊的欄位應該要有ctfmon字串值,如果消失了代表問題就出在這裡 4.修正辦法為:在右邊欄位點選右鍵新增字串值`Ctfmon`,然後再修改這個字串值的數值資料為`C:\\Windows\\system32\\ctfmon.exe` 完成後關閉。 5.接下來重新開機、登出再登入,或者直接手動執行 `C:\\Windows\\system32\\ctfmon.exe` 以後開機語言列就會正常出現了。 下載[RunCtfmon.reg](https://docs.google.com/file/d/0B76dgOP7VcsubWxHNFVxdFJLakU/edit?usp=sharing) 參考自 [http://www.mobile01.com/topicdetail.phpf=300&t=1646064&p=2](http://www.mobile01.com/topicdetail.phpf=300&t=1646064&p=2) ### 修理 Win 7輸入法整合器中文手寫 以下內容引用自[此](http://blog.yam.com/bestguard/article/49132253) 在命令提示字元下cmd 複製以下指令 ```regedit== %systemroot%\\system32\\regsvr32.exe "%systemroot%\\System32\\IME\\IMETC10\\applets\\IMTCCAC.dll" %systemroot%\\SysWOW64\\regsvr32.exe "%systemroot%\\SysWOW64\\IME\\IMETC10\\applets\\IMTCCAC.dll" ``` 這裡是要重新註冊IMTCCAC.dll,因為IMTCCAC.dll有分64位元和32位元 所以要依序在system32和SysWOW64的地方做重新註冊DLL 另外也要用登錄檔修正 COPY下列文字將它存成[ChtImePad64.reg](https://docs.google.com/file/d/0B76dgOP7VcsuUDR6eFg0TjJhVHc/edit?usp=sharing) (可能要先開啟副檔名才能修改副檔名) ```regedit== Windows Registry Editor Version 5.00 \[HKEY\_CLASSES\_ROOT\\CLSID\\{C0AA878E-97A5-44df-B7EF-2E732F7B2FEC}\] @="TC IME7 Handwriting Applet" \[HKEY\_CLASSES\_ROOT\\CLSID\\{C0AA878E-97A5-44df-B7EF-2E732F7B2FEC}\\Implemented Categories\] \[HKEY\_CLASSES\_ROOT\\CLSID\\{C0AA878E-97A5-44df-B7EF-2E732F7B2FEC}\\Implemented Categories\\{E081E1D6-2389-43CB-B66F-609F823D9F9C}\] \[HKEY\_CLASSES\_ROOT\\CLSID\\{C0AA878E-97A5-44df-B7EF-2E732F7B2FEC}\\InprocServer32\] @=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\   00,5c,00,53,00,59,00,53,00,54,00,45,00,4d,00,33,00,32,00,5c,00,49,00,4d,00,\   45,00,5c,00,69,00,6d,00,65,00,74,00,63,00,31,00,30,00,5c,00,61,00,70,00,70,\   00,6c,00,65,00,74,00,73,00,5c,00,69,00,6d,00,74,00,63,00,63,00,61,00,63,00,\   2e,00,64,00,6c,00,6c,00,00,00 "ThreadingModel"="Apartment" \[HKEY\_CLASSES\_ROOT\\CLSID\\{C0AA878E-97A5-44df-B7EF-2E732F7B2FEC}\\ProgID\] @="IMEPad.HWR.TCIME7" \[HKEY\_CLASSES\_ROOT\\CLSID\\{C0AA878E-97A5-44df-B7EF-2E732F7B2FEC}\\VersionIndependentProgID\] @="IMEPad.HWR.TCIME" ``` 然後執行剛剛存的[ChtImePad64.reg](https://docs.google.com/file/d/0B76dgOP7VcsuUDR6eFg0TjJhVHc/edit?usp=sharing) ### Android 工程串 ``` *#*#4636#*#* ``` ### Sony Xperia X Troubleshooting GPS Tip ``` *#*#7378423#*#* ``` Go to service tests > GPS > purge assistance data. Restart phone and try again. Normally it takes a while for the GPS to find your position after you have purge assistance data so have a little patience when you try again. ### SchTask ``` SchTasks /create /TN "DailyShutdown" /TR "shutdown -s -f -t 300" /sc DAILY /ST 18:15 /F /ru "NT AUTHORITY\SYSTEM" SchTasks /create /TN "Schedule Shutdown" /TR "shutdown -s -f -t 300" /sc ONCE /SD 13/05/2020 /ST 12:30 /F /ru "NT AUTHORITY\SYSTEM" ```