2015年11月26日 星期四

變更IE中我的最愛的路徑

變更IE中我的最愛的路徑

IE中預設的我的最愛的路徑是:C:\Users\你的帳號\Favorites
或是你在檔案總管中的位址列上輸入:%USERPROFILE%\Favorites


最愛的路徑目錄

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders


ref:http://ss64.com/nt/if.html
IF EXIST C:\logs\install.log (Echo Complete) ELSE (Echo failed)

IF EXIST %USERPROFILE%\Favorites  (Echo Complete) ELSE (Echo failed)


ref: http://forum.twbts.com/thread-10186-1-1.html
F :在批次檔中執行條件處理。

指令詳解:

IF [NOT] ERRORLEVEL number command
IF [NOT] string1==string2 command
IF [NOT] EXIST filename command

2015年11月25日 星期三

windows update server (WSUS) and sysrep

net stop wuauserv


reg.exe delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v SusClientId /f

reg.exe delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v SusClientIDValidation /f


net start wuauserv


wuauclt.exe /resetauthorization /detectnow

************************************************************************************


sysrep:

ref:
https://technet.microsoft.com/zh-tw/library/cc721973(v=ws.10).aspx

Sysprep 命令列選項

Sysprep 可搭配使用下列命令列選項:
sysprep.exe [/oobe | /audit] [/generalize] [/reboot | /shutdown | /quit] [/quiet] [/unattend:answerfile]

 

選項描述
/audit
將電腦重新啟動成稽核模式。稽核模式可讓您將其他驅動程式或應用程式新增至 Windows。您也可以在將 Windows 安裝送交給使用者之前先測試它。
如果有指定自動的 Windows 安裝檔案,Windows 安裝程式的稽核模式就會執行 auditSystem 與 auditUser 設定階段。
/generalize
準備要進行映像處理的 Windows 安裝。如果指定此選項,就會移除 Windows 安裝中所有唯一的系統資訊。安全性識別碼 (SID) 會重設、所有系統還原點都會清除,並且事件記錄也會予以刪除。
下次電腦啟動時,specialize 設定階段就會執行。然後會建立新的安全性識別碼 (SID),並重設 Windows 啟用的時鐘 (如果時鐘尚未重設三次的話)。
/oobe
將電腦重新啟動成 Windows 歡迎畫面模式。Windows 歡迎畫面可讓使用者自訂其 Windows 作業系統、建立使用者帳戶、命名電腦及其他工作。回應檔案之 oobeSystem 設定階段中的任何設定,會在 Windows 歡迎畫面啟動之前立即處理。
/reboot
重新啟動電腦。使用此選項可稽核電腦,並驗證首次執行經驗是否運作正常。
/shutdown
Sysprep 完成之後關閉電腦。
/quiet
執行 Sysprep 而不顯示螢幕確認訊息。如果您要自動化 Sysprep,請使用此選項。
/quit
在執行指定的命令後關閉 Sysprep。
/unattend:answerfile
在自動安裝期間將回應檔案中的設定套用至 Windows。
answerfile
指定要使用之回應檔案的路

update WSUS client ID:

net stop wuauserv


reg.exe delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v SusClientId /f

reg.exe delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v SusClientIDValidation /f


net start wuauserv


wuauclt.exe /resetauthorization /detectnow




Ref:
http://ageansea.pixnet.net/blog/post/28915393

Windows 背景自動更新程式 Wuauclt.exe


Wuauclt.exe = A Windows Update AutoUpdate Client, Background process which checks with Microsoft website for updates to the operating system.
Wuauclt有 2 個非常有用的參數:Detectnow 和 Resetauthorization 。
◎ Detectnow 
在命令提示字元下輸入 wuauclt .exe /detectnow ,可以立即讓Client端立即與 WUS Server 聯繫,檢測是否有新的Service Pack。 在Client端,可以在OS的安裝目錄下檢查 WindowsUpdate.log 文件,看是否與Server聯繫檢測更新,如果更新過程有錯誤,也可在該文件中查看錯誤原因。
如果是在WSUS Server上無法使用WSUS管理主控台列出的某些更新,則是需要指定reset 參數。
◎ Resetauthorization 
WUS 在Client 端使用了 Cookie 儲存一些信息。默認該 Cookie 1小時後失效,如果你在使用 detectnow 參數立即檢查Client 端Service Pack 時發現 Cookie 過期無法更新時可以使用 Resetauthorization 重新申請對話。 在命令提示字元下輸入
wuauclt .exe /resetauthorization /detectnow
管理員在debug時,除了可以查看Client端的 WindowsUpdate.log 文件外,還可以在Server端的 %ProgramFiles%\Microsoft Windows Update Services\ 目錄下檢查 LogFiles\SoftwareDistribution.log 文件進行偵錯。




ref:http://ss64.com/nt/reg.html

REG.exe

Read, Set or Delete registry keys and values, save and restore from a .REG file.
Syntax:

   REG QUERY [ROOT\]RegKey /v ValueName [/s]
   REG QUERY [ROOT\]RegKey /ve  --This returns the (default) value
   
   REG ADD [ROOT\]RegKey /v ValueName [/t DataType] [/S Separator] [/d Data] [/f]
   REG ADD [ROOT\]RegKey /ve [/d Data] [/f]  -- Set the (default) value

   REG DELETE [ROOT\]RegKey /v ValueName [/f]
   REG DELETE [ROOT\]RegKey /ve [/f]  -- Remove the (default) value
   REG DELETE [ROOT\]RegKey /va [/f]  -- Delete all values under this key

   REG COPY  [\\SourceMachine\][ROOT\]RegKey [\\DestMachine\][ROOT\]RegKey

   REG EXPORT [ROOT\]RegKey FileName.reg
   REG IMPORT FileName.reg
   REG SAVE [ROOT\]RegKey FileName.hiv
   REG RESTORE \\MachineName\[ROOT]\KeyName FileName.hiv
   
   REG LOAD KeyName FileName
   REG UNLOAD KeyName
   
   REG COMPARE [ROOT\]RegKey [ROOT\]RegKey [/v ValueName] [Output] [/s]
   REG COMPARE [ROOT\]RegKey [ROOT\]RegKey [/ve] [Output] [/s]

Key:
   ROOT :
         HKLM = HKey_Local_machine (default)
         HKCU = HKey_current_user
         HKU  = HKey_users
         HKCR = HKey_classes_root

   ValueName : The value, under the selected RegKey, to edit.
               (default is all keys and values)

   /d Data   : The actual data to store as a "String", integer etc

   /f        : Force an update without prompting "Value exists, overwrite Y/N"

   \\Machine : Name of remote machine - omitting defaults to current machine.
              Only HKLM and HKU are available on remote machines.

   FileName  : The filename to save or restore a registry hive.

   KeyName   : A key name to load a hive file into. (Creating a new key)

   /S        : Query all subkeys and values.

   /S Separator : Character to use as the separator in REG_MULTI_SZ values
                  the default is "\0" 

   /t DataType  : REG_SZ (default) | REG_DWORD | REG_EXPAND_SZ | REG_MULTI_SZ

   /reg:32   : Force REG.exe to write to the 32-bit registry location
   /reg:64   : Force REG.exe to write to the 64-bit registry location

             By default a 32-bit process (such as an SCCM client or a 32 bit MSI installer)
             on a 64 bit machine, will use a 32-bit view of the registry: HKLM\SOFTWARE\Wow6432Node
             Use the /REG switch to over-ride this.

   Output    : /od (only differences) /os (only matches) /oa (all) /on (no output)
Notes: 
Any of the above commands can be run against a remote machine by adding \\MachineName to the command line, assuming the Remote Registry Service is running.
Registry data stored under HKCU will be visible and writable by the currently logged in user.
Registry data stored under HKLM will be visible to all users and writable by administrators.
REG RESTORE has a tendency not to work, possibly due to firewall issues, Export and Import are much more reliable.
Backslash characters