Sunday, 8 September 2013

VBScript - Reading From Text File breaks midway

VBScript - Reading From Text File breaks midway

I have a text file which contains usernames and passwords which need to be
logged in. I'm attempting to make a VBScript file to automate this
process. The text file's syntax is
username
password
username
password
etc etc
and is a total of 738 lines.
The code I currently have is
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Users\Jacob\Desktop\logins.txt",
ForReading)
Set WshShell = WScript.CreateObject("WScript.Shell")
Const ForReading = 1
Dim strUsername
Dim strPassword
wshshell.AppActivate "Notepad"
Do Until objFile.AtEndOfStream
strUsername = objFile.ReadLine
strPassword = objFile.ReadLine
wshshell.sendkeys strUsername
wshshell.sendkeys "~"
wshshell.sendkeys strPassword
wshshell.sendkeys "~"
Loop
which I'm using simply to make sure it works by having it write to a blank
text file. (Later notepad will be replaced by the login executable, I
already know that part works).
The code works fine until it hits line 221 of the text file, where it
breaks. It exports a bunch of random garbage and then stops.
Any help is greatly appreciated.
Edit: Here is the garbage text which comes at the end of the written text
file. You can see that there are still remnants of what should come out.
.[redacted username].22bssddd2222ent000.2wlllkarsstt00....000h8b6b99b88uub2
.....ttttte0000mp00...gh.rrlll00225..gbu .....0022sdg [redacted password]
.proeflussssddd ..22le.pu6....225500s.gl.iteee.55.uuu.hmadttn..0dl
tsssssbeeee0000nsssss0000000ssssdssdbuuuz22dddd000buuu.jj2222 b4....3
.j00000000b
y.
bb.ddddssgg.2222ssgg05uuudbeeeeen......hh00222l11.....tdddd.nn
00000 ll0ssssau0s000ssssss bbddddlll.ttttl......s be
.o222
b.ddddddutttt ll000buc11e000000utttt bbb.eeeeee0000seeeee5
mmssss000000unnnttttnnn bb000..s.dsssssss.fa000000 2 .....k000.4tnnn
.....bbbseeeu
.n.2te....s
7e9bbmv00000000tttteeee.mttseetnn2222222r0000000000.u.ddd0000000.111ddddge11111ssddddoo000.ssssssnnnn.uutnnn772
.bbg.......66teeb000000ee1114lrd00002222nsp

No comments:

Post a Comment