Notepad can be scripted, but not with batch code.
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "notepad c:\temp\test.txt" 'Point to existing file
WScript.Sleep 1000
WshShell.AppActivate "test - Notepad" 'Must match window title(handle)
WScript.Sleep 1000
WshShell.SendKeys "^(a)"
WScript.Sleep 1000
WshShell.SendKeys "{DEL}"
WScript.Sleep 1000
WshShell.SendKeys "1. Open notepad"
WScript.Sleep 500
WshShell.SendKeys "{ENTER}"
WScript.Sleep 500
WshShell.SendKeys "2. Delete contents"
WScript.Sleep 500
WshShell.SendKeys "{ENTER}"
WScript.Sleep 500
WshShell.SendKeys "3. Add new Lines"
WScript.Sleep 500
WshShell.SendKeys "{ENTER}"
WScript.Sleep 500
WshShell.SendKeys "4. Save"
WScript.Sleep 500
WshShell.SendKeys "{ENTER}"
WScript.Sleep 2500
WshShell.SendKeys "^(s)"
WScript.Sleep 500
WshShell.SendKeys "%(f)"
WScript.Sleep 2500
WshShell.SendKeys "x"
WScript.Sleep 500
Notes:
1. Script opens an existing file
test.txt. Change if necessary.
2. Window handle format is
filename - Notepad; filename does not contain the extension.
3. Script will overwrite existing file; take precautions if necessary
Good luck.
Creating files with
VBScript and
sendkeys is very inefficient.