[英]How to use VBScript to open notepad and paste current date with DDMMYYYY format in it?
如何使用 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
你们能帮我解决这个问题吗?
你想要的日期格式: 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.