2017-07-28 51 views
-2

如何使用VBScript打開記事本並以DDMMYYYY格式粘貼當前日期?如何使用VBScript打開記事本並將DDMMYYYY格式的當前日期粘貼到記事本中?

當我使用下面的代碼時,我得到了DD/MM/YYYY格式的輸出。我需要它在DDMMYYYY格式。

set WshShell = WScript.CreateObject("WScript.Shell") 

call WshShell.Run("%windir%\system32\notepad.exe") 

Dim aDate 

aDate = Date() 

WScript.Sleep 4000 

WshShell.SendKeys aDate 

請問你們能幫我解決嗎?

+2

前問一個問題,請至少做一個小的研究。 – GTAVLover

+1

[如何使用VBScript打開記事本並粘貼當前日期?](https://stackoverflow.com/questions/45341320/how-to-use-vbscript-to-open-notepad-and-paste -durrent-date-in-it) –

+1

[格式化當前日期和時間]的可能重複(https://stackoverflow.com/questions/22574092/format-current-date-and-time) – Lankymart

回答

0

你想要的日期格式:DDMMYYYY(不常見的斜槓)

這應該爲你工作:

Dim WshShell: Set WshShell = WScript.CreateObject("WScript.Shell") 

WshShell.Run("%windir%\system32\notepad.exe") 
WScript.Sleep 4000 

Dim aDate: aDate = WScript.CreateObject("System.Text.StringBuilder").AppendFormat("{0:dd}{0:MM}{0:yyyy}", Now).ToString() 

WshShell.SendKeys aDate 
相關問題