I'm trying to use a combination of scripts and batch files to automate some tasks I do when setting up computers. I need to open a specific file in notepad, search for some text, and when it finds that text, replace it with something else. I'm having trouble getting the vbscript file to interact with notepad. I have a batch file that runs my .vbs file and .bat file. I'm using sendkeys to access notepads menu and select the replace option and then enter the find text and replace text. My knowledge of vbscript is very limited so I could be heading in the wrong direction entirely. What I have so far is:
set WshShell = CreateObject("WScript.Shell"
WScript.Sleep 500
WshShell.SendKeys "^h" 'Shortcut for Replace
WshShell.SendKeys "search text" 'The text I want to search for
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "Replace text" 'The text I want to enter
WshShell.SendKeys "{Enter}"
I can't get the vbscript to actually send the keystrokes to notepad. What am I doing wrong? Does anybody have any tips on this or a better way to accomplish this?
set WshShell = CreateObject("WScript.Shell"
WScript.Sleep 500
WshShell.SendKeys "^h" 'Shortcut for Replace
WshShell.SendKeys "search text" 'The text I want to search for
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "Replace text" 'The text I want to enter
WshShell.SendKeys "{Enter}"
I can't get the vbscript to actually send the keystrokes to notepad. What am I doing wrong? Does anybody have any tips on this or a better way to accomplish this?