OK...new to VB. Ihave the following script that i will use to change the password.I want the first inbox to pull the password from the .bat, the second inbox will prompt the user to change it.
'--the Replace function; replaces occurences of text in a file.
'--it will replace what is entered, not necessarily on a whole-word basis.
dim fil, s, r, s1, s2, snew, r1
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
set MONTHLYPWD
'--get filename and open it. read all text into a string var.
r = inputbox("NonReg.bat", "Change NA Domain Password", "C:\java\New Folder\Text Ops\TestNonReg.bat")
if fso.FileExists(r) = false then
msgbox "There's no such file!", 64, "That's not it"
wscript.Quit
end if
set fil = fso.OpenTextFile(r, 1)
s = fil.ReadAll
fil.Close
set fil = nothing
'--get text to replace and new text.
s1 = inputbox("Old Password", "Change NA Domain Password", MONTHLYPWD)
s2 = inputbox("New Password?", "Change NA Domain Password")
r1 = msgbox("Is the replacement case-sensitive?", 36, "Case Sensitive?")
if r1 = 6 then
snew = replace(s, s1, s2, 1, -1, 0) '-- 1 is starting pos., -1 is to replace all occur., 0 is for case sens.
else
snew = replace(s, s1, s2, 1, -1, 1) '-- 1 is for not case sens.
end if
'--delete the old file and write the changed string in its place.
fso.DeleteFile r, true
set fil = fso.CreateTextFile(r)
fil.Write snew
fil.Close
set fil = nothing
msgbox "All done", 0
Having problems with the S1 line and getting it to return , just one instance of the, the password in the box. I can do it once but once the string is defined in the S1 line, I am unable to change the password. It retains the old password from the defined string and the program is a one time deal. I don't want the user to have to remember the password is what I am getting at.