Jamyy's Weblog

批次安裝 iTALC Client

by Jamyy on 四月.18, 2012, under Coding

目的: 安裝 iTALC Client 後, 取出相關檔案與機碼設定值並撰寫批次檔, 方便在其他電腦批次安裝

環境: Windows XP, Windows 7


※ 64 位元作業系統必須執行 64 位元的 iTALC 才能隱藏 Tray Icon.

Step 1. 依照 【圖解 iTALC 安裝、設定與使用方法】完成 iTALC Client (Student) 安裝與設定作業

Step 2. 複製 iTALC 相關檔案到網路磁碟機

視窗鍵 + R → cmd
net use z: \\file.server\share /user:myaccount
cd "\Documents and Settings\All Users\Application Data" (XP)
cd "\Users\All Users" (Win 7)
xcopy iTALC z:\iTALC\appdata\iTALC\ /E
cd "\Program Files"
xcopy iTALC z:\iTALC\progfile32\iTALC\ /E (32 位元作業系統)
xcopy iTALC z:\iTALC\progfile64\iTALC\ /E (64 位元作業系統)

Step 3. 匯出或製作機碼檔 (擇一)

匯出: 視窗鍵 + R → regedit

匯出: HKEY_LOCAL_MACHINE\SOFTWARE\iTALC Solutions 到 z:\iTALC\italc.reg

製作: 視窗鍵 + R → notepad z:\iTALC\italc.reg

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\iTALC Solutions]

[HKEY_LOCAL_MACHINE\SOFTWARE\iTALC Solutions\iTALC]

[HKEY_LOCAL_MACHINE\SOFTWARE\iTALC Solutions\iTALC\Authentication]
"EncodedLogonACL"=""
"KeyAuthenticationEnabled"="1"
"LogonAuthenticationEnabled"="0"
"LogonGroups"=""
"PermissionRequiredWithKeyAuthentication"="0"
"PermissionRequiredWithLogonAuthentication"="0"
"PrivateKeyBaseDir"="$GLOBALAPPDATA\\keys\\private"
"PublicKeyBaseDir"="$GLOBALAPPDATA\\keys\\public"
"SameUserConfirmationDisabled"="0"

[HKEY_LOCAL_MACHINE\SOFTWARE\iTALC Solutions\iTALC\DemoServer]
"Backend"="0"
"Multithreaded"="1"

[HKEY_LOCAL_MACHINE\SOFTWARE\iTALC Solutions\iTALC\Logging]
"LimittedLogFileSize"="0"
"LogFileDirectory"="%TEMP%"
"LogFileSizeLimit"="-1"
"LogLevel"="0"
"LogToStdErr"="0"
"LogToWindowsEventLog"="0"

[HKEY_LOCAL_MACHINE\SOFTWARE\iTALC Solutions\iTALC\Network]
"CoreServerPort"="11100"
"DemoServerPort"="11400"
"FirewallExceptionEnabled"="1"
"HttpServerEnabled"="0"
"HttpServerPort"="5800"

[HKEY_LOCAL_MACHINE\SOFTWARE\iTALC Solutions\iTALC\Paths]
"GlobalConfiguration"="$APPDATA\\GlobalConfig.xml"
"PersonalConfiguration"="$APPDATA\\PersonalConfig.xml"
"SnapshotDirectory"="$APPDATA\\Snapshots"

[HKEY_LOCAL_MACHINE\SOFTWARE\iTALC Solutions\iTALC\Service]
"Arguments"=""
"Autostart"="1"
"HideTrayIcon"="1"

[HKEY_LOCAL_MACHINE\SOFTWARE\iTALC Solutions\iTALC\VNC]
"CaptureLayeredWindows"="0"
"LowAccuracy"="1"
"PollFullScreen"="1"

Step 4. 製作批次檔

notepad z:\iTALC\go.bat

@echo off
echo Please wait...
%SystemDrive%

ver | findstr " 5." > nul
if %errorlevel% equ 0 goto xp

cd "\Users\All Users"
mkdir iTALC\keys\public\teacher > nul
copy %~dp0appdata\iTALC\keys\public\teacher\key iTALC\keys\public\teacher\ > nul
goto go-on

:xp
cd "\Documents and Settings\All Users\Application Data"
xcopy %~dp0appdata .\ /e /q /y > nul

:go-on
cd "\Program Files"

set prog=progfile32
set | findstr "ProgramW6432" > nul
if %errorlevel% equ 0 set prog=progfile64

xcopy %~dp0%prog% .\ /e /q /y > nul
cd iTALC
start /wait ica.exe -quiet -registerservice
start /wait imc.exe -s Network/FirewallExceptionEnabled=1
regedit /s %~dp0italc.reg
net start "iTALC Client" > nul
exit

Step 5. 到其他電腦執行批次檔安裝 iTALC Client, 安裝後無需調校即可立刻接受監控

XP:

視窗鍵 + R → cmd
net use z: \\file.server\share /user:myaccount
z:\iTALC\go

Win 7:

視窗鍵 → 輸入 cmd → 在 cmd 圖示上按右鍵, 點選 "以系統管理員身分執行"
net use z: \\file.server\share /user:myaccount
z:\iTALC\go

批次檔重點備忘

1. 取得批次檔所在路徑:

%~d0 取得 z:
%~p0 取得 \iTALC\
%~dp0 取得 z:\iTALC\

參考資料:

2. Windows 7 無法用 xcopy 寫入 \Users\All Users\, 所以先 mkdir 再 copy 檔案到指定路徑

Windows 5.0 → Windows 2000
Windows 5.1 → Windows XP
Windows 5.2 → Windows 2003
  以上 All Users 目錄在 %SystemDrive%\Documents and Settings\All Users

Windows 6.0 → Windows Vista
Windows 6.1 → Windows 7
  以上 All Users 目錄在 %SystemDrive%\Users\All Users

參考資料: Batch File: Easy Way to Detect Windows OS Version - The Grim Admin

3. 啟動程序並等候執行完畢:

start /wait command-name.exe

參考資料: fpschultze - Batch Scripting - Wait For Process Termination - News

4. 若要在執行檔中暫停 n 秒, 如同 Linux Shell Script 的 sleep 5 (暫停五秒):

XP: ping 127.0.0.1 -n 5 -w 1000 > nul
Win 7: timeout /t 5 /nobreak > nul

參考資料: The Will Will Web | 如何在批次檔(Batch)中實現 sleep 命令讓任務暫停執行 n 秒

5. 悄悄寫入機碼: regedit /s regfile.reg

6. imc.exe -s 那行是寫入 Windows 防火牆規則開放 ica.exe 通行, 亦可改用以下方式開放 TCP 11100 port:

XP: netsh firewall add portopening TCP 11100 "Windows Security Enhancer"
Win 7: netsh advfirewall firewall add rule name="Windows Security Enhancer" protocol=TCP localport=11100 dir=in action=allow

其中, "Windows Security Enhancer" 是防火牆規則名稱, 可隨意自訂

若 XP 無法使用 netsh 指令建立防火牆規則, 可另行編輯、匯入機碼:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts\List]
"11100:TCP"="11100:TCP:*:Enabled:Windows Security Enhancer"

參考資料:

7. 完整移除 iTALC Client

視窗鍵 + R → cmd
C:\Program Files\iTALC\uninstall.exe
cd \Documents and Settings\All Users\Application Data (XP)
cd \Users\All Users (Win 7)
rmdir /q /s iTALC (Win 7 須以管理員身分執行 cmd 才能執行)
regedit → 刪除 HKEY_LOCAL_MACHINE\SOFTWARE\iTALC Solutions

8. 判斷 32 位元或 64 位元系統環境

set | findstr "ProgramW6432"
64 位元作業系統會有 ProgramW6432 環境變數, 32 位元環境則無

參考資料: 64bit - Detect whether current Windows version is 32 bit or 64 bit - Stack Overflow



: