顯示具有 電腦-Windows-指令 標籤的文章。 顯示所有文章
顯示具有 電腦-Windows-指令 標籤的文章。 顯示所有文章

2018年1月16日 星期二

電腦-Windows-Notepad++開啟多個視窗

需要同時開啟多個Notepad++,在網路看到2個方法
1.
http://kasonblog.blogspot.tw/2012/03/notepad-command-line-multiinst.html
建立Notepad++捷徑,多加上-multiInst -nosession 參數

2.
http://oh-ziway.blogspot.tw/2012/08/notepad.html
在Notepad++工具列,Run => Open in another instance

決定採用第一方式。


2017年2月14日 星期二

電腦-windows 系統環境變數

windows 系統環境變數

Windows永久變更系統環境變數的話,可修改註冊表(registry)的參數內容。
修改目前使用者環境變數:
HKEY_CURRENT_USER\Environment

修改系統環境變數:
[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment]
REM 設定環境變數TEST為%PATH%的內容
reg add "HKEY_CURRENT_USER/Environment" /v TEST /t REG_EXPAND_SZ /d "%PATH%" /f
REM 設定環境變數TEST為%PATH%
reg add "HKEY_CURRENT_USER/Environment" /v TEST /t REG_EXPAND_SZ /d ^%PATH^% /f
REM 刪除環境變數TEST
reg delete "HKEY_CURRENT_USER/Environment" /v TEST /f

修改後不會立即生效。


批次檔(batch)的設定環境變數
set patch=新增變數內容;%PATH%(原有變數內容)
修改的環境變數內容僅止於執行的批次檔。

參考資料:
修改Windows系統環境變數
修改環境變數
批次檔BAT中應用Windows的36個環境變數

%ALLUSERSPROFILE%:All Users設定檔的資料夾位置。
%APPDATA%:目前使用者的Application Data資料夾位置。
%CD%:目前的工作資料夾。
%CLIENTNAME%:目前使用者的NETBIOS電腦名稱。
%CMDCMDLINE%:處理目前命令提示字元視窗命令的cmd.exe的完整路徑。
%CMDEXTVERSION%:目前Command Processor Extensions的版本。
%CommonProgramFiles%:Common Files資料夾的路徑。
%COMPUTERNAME%:電腦名稱。
%COMSPEC%::命令提示字元視窗的解譯程式路徑,通常與%CMDCMDLINE%相同。
%DATE%:目前的系統日期。
%ERRORLEVEL%:最近執行過的命令的錯誤碼;非零的值表示發生過的錯誤碼。
%HomeDrive%:使用者目錄的磁碟機。
%HomePath%:使用者家目錄。
%HOMESHARE%:目前使用者共用資料夾的網路路徑。
%LOGONSEVER%:目前使用者所登入的網路控制器名稱。
%NUMBER_OF_PROCESSORS%:電腦的處理器數量。
%OS%:作業系統名稱,其值固定為Windows_NT。
%Path%:執行檔的搜尋路徑。
%PATHEXT%:作業系統是為執行檔的副檔名。
%PROCESSOR_ARCHITECTURE%:處理器的架構名稱,例如x86。
%PROCESSOR_IDENTFIER%:說明處理器的文字(不一定會有此環境變數)。
%PROCESSOR_LEVEL%:處理器的model number。
%PROCESSOR_REVISION%:處理器的revision number。
%ProgramFiles%:應用程式目錄,預設是C:\Program Files。
%PROMPT%:目前解譯程式的命令提示字串。
%RANDOM%:顯示0到32767之間的十進位整數亂數。
%SESSIONNAME%:連上終端伺服器的session names。
%SystemDrive%:系統磁碟機,預設是C:。
%SystemRoot%:系統根目錄,預設是C:\WINNT或C:\WINDOWS。
%SystemDirectory%:系統目錄,預設是C:\WINNT\System32或C:\WINDOWS\System32。
%Temp%、%Tmp%:暫存檔目錄。
%TIME%:目前的系統時間。
%UserDomain%:包含使用者帳號的網域名稱,或者電腦名稱。
%UserName%:使用者帳號名稱。
%USERPROFILE%:目前使用者的設定檔路徑。
%WinDir%:Windows目錄,預設是C:\WINNT或C:\WINDOWS。

系統存取環境變數的順序

1.Autoexec.bat
2.系統變數
3.使用者變數
也就是說,相同變數名稱同時經由上述三種方式設定之後,
在『使用者變數』所設定的變數值,會蓋過在『系統變數』或『Autoexec.bat』所設定的值;
而在『系統變數』所設定的值,會蓋過在『Autoexec.bat』所設定的值。

Windows系統內建的常見環境變數

以下環境變數可以在『檔案總管』使用,或在DOS視窗以echo指令顯示其值;
%SystemDrive%:系統磁碟機,預設是C:
%SystemRoot%:系統根目錄,預設是C:\WINNT或C:\WINDOWS
%SystemDirectory%:系統目錄,預設是C:\WINNT\System32或C:\WINDOWS\System32
%WinDir%:Windows目錄,預設是C:\WINNT或C:\WINDOWS
%ProgramFiles%:應用程式目錄,預設是C:\Program Files
%Temp%、%Tmp%:暫存檔目錄 %HomeDrive%:使用者目錄的磁碟機
%HomePath%:使用者家目錄

以下的環境變數只能在DOS視窗以echo指令顯示其值:
%OS%:作業系統名稱,其值固定為Windows_NT
%UserDomain%:包含使用者帳號的網域名稱,或者電腦名稱
%UserName%:使用者帳號名稱

電腦-windows 定時校時設定。

windows client 端校時設定批次檔

=====
@echo off

REM 停止 Windows Time 服務
net stop w32time

REM 變更預設 Time Server (GUI 介面下拉 NTP Server 選單第一個內容)
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers /v 0 /t REG_SZ /d "tick.stdtime.gov.tw" /f

REM 設定 NTP Server (可設定多組)
w32tm /config /syncfromflags:manual /manualpeerlist:"tick.stdtime.gov.tw,0x1 watch.stdtime.gov.tw,0x1"

REM 設定每 3600 秒校時一次
reg add HKLM\SYSTEM\CurrentControlSet\services\W32Time\TimeProviders\NtpClient /v SpecialPollInterval /t REG_DWORD /d 3600 /f

REM 啟動 Windows Time 服務
net start w32time

REM 開機自動啟動 Windows Time 服務
sc config w32time start= auto

REM 網路存在時啟用 Windows Time 服務,網路不存在時停止 Windows Time 服務
sc triggerinfo w32time start/networkon stop/networkoff

======
參考資料:

2017年2月13日 星期一

電腦-windows 硬碟空間整理清除

windows 硬碟定期整理清除,保持可用空間。

1.windows更新時會存放下載安裝檔的位置
C:\Windows\SoftwareDistribution\Download
先停用相關服務
Background Intelligent Transfer Service
Cryptographic Services
Windows Update

2.刪除Window更新記錄
C:\Windows\SoftwareDistribution\DataStore\logs
C:\Windows\SoftwareDistribution\DataStore\DataStore.edb
先停用Windows Update服務

參考資料:
硬碟空間又不夠了
刪除Window更新記錄
Windows 7 如何刪除更新 (Windows Update) 留下的檔案 ?

2016年12月27日 星期二

電腦 windows mklink 用法 (symbolic link)

windows mklink 用法
Linux上, symbolic link可以將檔案或資料夾產生一個或多各連結,
在 Windows 的 mklink ,也有相同功能。
用administrator 開啟命令提示字元,輸入mklink /?






1.建立
建立d:\temp連結目錄,指向e:\temp
mklink /d d:\temp e:\temp
建立d:\temp連結目錄,指向網路磁碟
mklink /d d:\temp \\138.20.1.141\e$\temp
2.刪除
rmdir d:\temp
rd d:\temp

2016年12月20日 星期二

電腦 windows 網域環境中出現工作站與網域控制器信任失敗問題

windows 網域環境中出現工作站與網域控制器信任失敗問題

工作站使用網域帳號登入時,出現 " the trust relationship between this workstation and the primary domain failed "或 " 此工作站和主要網域間的信任關係失敗 " 的問題。

1.使用本機管理者帳號登入,退出網域及重新加入網域。

2.使用windows內建 powershell的 Reset-ComputerMachinePassword 指令
   a.下載powershell 4.0 ,安裝
       https://www.microsoft.com/en-us/download/details.aspx?id=40855
   b.執行 Reset-ComputerMachinePassword -Server <Name of any domain controller> -Credential <domain admin account>
       <Name of any domain controller> 為網域控制器主機名稱,如:dc.domian.com
       <domain admin account> 為網域管理者帳號,如: domain\administrator


參考資料

此工作站和主域间的信任关系失败

 

How To Fix Domain Trust Issues in Active Directory

 

DON’T REJOIN TO FIX: The trust relationship between this workstation and the primary domain failed

2016年11月22日 星期二

電腦 windows使用winscp的指令功能

在windows的cmd模式,使用ftp指令無法下載。
決定使用winscp來取代。

建立參數檔:script.txt
option batch abort
option confirm off
option transfer binary
open ftp://LoginID:LogPwd@FTP_Host
put d:\examplefile.txt
close
exit

建立執行檔:ftp.bat
winscp.com /script=\script.txt /ini=nul /log=\session.log

將ftp.bat、script.txt放在winscp資料夾
執行ftp.bat即可。也可寫入排程固定執行。



使用sftp
sftp://LoginID:LogPwd@FTP_Host -hostkey="ssh-rsa 1024  XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:X:XX:XX:XX:XX"

使用scp
winscp.exe scp://test@example.com:2222 /privatekey=mykey.ppk

使用ftps
winscp.exe ftps://martin@example.com /implicit /certificate="xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"

參考資料:
SFTP使用WinSCP
Useful Scripts
Scripting and Task Automation
Example
In the example below, WinSCP connects to example.com server with account user, downloads file and closes the session. Then it connects to the same server with the account user2 and uploads the file back.
# Connect
open sftp://user:password@example.com/ -hostkey="ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
# Change remote directory
cd /home/user
# Force binary mode transfer
option transfer binary
# Download file to the local directory d:\
get examplefile.txt d:\
# Disconnect
close
# Connect as a different user
open sftp://user2:password@example.com/
# Change the remote directory
cd /home/user2
# Upload the file to current working directory
put d:\examplefile.txt
# Disconnect
close
# Exit WinSCP
exit
Save the script to the file example.txt. To execute the script file use the following command.
winscp.com /ini=nul /script=example.txt
==
For simple scripts you can specify all the commands on command-line using /command switch:
winscp.com /ini=nul /command "open sftp://user:password@example.com/ -hostkey=""ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx""" "get examplefile.txt d:\" "exit"
==
In Windows batch file, you can use ^ to split too long command-line to separate lines by escaping following new-line character:
winscp.com /ini=nul /command ^
    "open sftp://user:password@example.com/ -hostkey=""ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx""" ^
    "get examplefile.txt d:\" ^
    "exit"
See other useful example scripts.