You can use the method SendKeysto send the Alt+ shortcut F4to the window you want to close. This window must be active at the moment, so you also need to call AppActivateright before SendKeys.
Basically, you will need something like this:
Set oShell = CreateObject("WScript.Shell")
oShell.AppActivate "Untitled - Notepad"
oShell.SendKeys "%{F4}"
You can add checks and slight delays to make your script more reliable:
Set oShell = CreateObject("WScript.Shell")
If oShell.AppActivate("Untitled - Notepad") Then
WScript.Sleep 500
oShell.SendKeys "%{F4}"
End If
Edit: (answer to your comment / question about VBScript resources.)
- VBScript, , , :
VBScript , script-coding.info — . , , VBScript, .