How to use VBScript to open notepad and paste current date in DDMMYYYY format?
When I use the below code, I get the output in DD/MM/YYYY format. I want it in DDMMYYYY format.
set WshShell = WScript.CreateObject("WScript.Shell")
call WshShell.Run("%windir%\system32\notepad.exe")
Dim aDate
aDate = Date()
WScript.Sleep 4000
WshShell.SendKeys aDate
Could you guys please help me on this one?
The Date format you want: DDMMYYYY (without common slashes)
This should work for you:
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.