Hi,
I have to search for the "Patrol->EzmeGJz3xqYSY+s+8S2On89D+tU…" from below text in which EzmeGJz3xqYSY+s+8S2On89D+tU is an encrypted password, which i want to copy and replace in another txt file, how can i do that? specially when I can not find with hardcoded value, because this password will keep changing in every month.

[replacing I can do, but I want to know how can I copy it, ]

Creating new policy ...
Site policy = 'SOFTWARE\BMC Software\Patrol\SecurityPolicy_v3.0\site…
Appl policy = 'SOFTWARE\BMC Software\Patrol\SecurityPolicy_v3.0\agen…
ModuleName C:\Program Files\BMC Software\common\security\bin_v3.0\Window…
BPW Module, Version 1.0|ess3.0.11.0|win32|Oct 24 2007|19:34:56
Patrol->EzmeGJz3xqYSY+s+8S2On89D+tU…
BPW Module, Version 1.0|ess3.0.11.0|win32|Oct 24 2007|19:34:56
Anticipated decryption error -1.
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Community Chosen Answer

2
Provided the line "Patrol->" always precedes the password you want to copy, here is how I would do it:





strPathToTxt = inputbox("Enter path to text file here")
Set objFSO = Createobject("scripting.filesystemobject")

'\\ Evaluate if your file exists, if it does, open the file

If objFSO.fileExists(strPathToTxt) then
Set objFile = objFSO.OpenTextFile(strPathToTxt)
Else
wscript.echo "File not found!"
Wscript.quit
End if


'\\ Turn the file into a string, then split the string into an array on a line-by-line basis

strcontents = objFile.ReadAll
arrcontents = Split(strcontents, vbnewline)


'\\ Evaluate the array for lines that contain "Patrol->"

For Each strline in arrcontents
if instr(1,Lcase(strline),"patrol->",1) then

'\\ when found, split the line into an array based on the > character

arrpassword = Split(strline,">")
end if
Next


'\\ Now arrpassword(1) contains everything after ">" on the line that contained Patrol->
'\\ Set arrpassword(1) to a single string

strPassword = arrpassword(1)

'\\ Profit!

wscript.echo strPassword

Answered 08/14/2009 by: Jsaylor
Second Degree Blue Belt

Please log in to comment
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
Thanks for the reply....I will try it, and let you know regarding the same.
Answered 08/14/2009 by: abking99
Second Degree Blue Belt

Please log in to comment
0
Hi,
it is displaying msgbox but not displaying password in it.1st time when i run this script, it gives type mismatch error at line 37
Answered 08/14/2009 by: abking99
Second Degree Blue Belt

Please log in to comment
0
That means that it cannot find a line in your text document that contains "Patrol->"

Is that string not common to what you're looking for?
Answered 08/14/2009 by: Jsaylor
Second Degree Blue Belt

Please log in to comment
0
that text contains patrol, it is the same text which i have given in the 1st post.
if i copy ur script as it is then it gives error on line 35 by mistake i said its 37.
the error line is:
strPassword = arrpassword(1)
if i remove (1) then it shows msgbox but does not show password in that
Answered 08/14/2009 by: abking99
Second Degree Blue Belt

Please log in to comment
0
You were right dude....your script is perfect
Answered 08/14/2009 by: abking99
Second Degree Blue Belt

Please log in to comment
0
You can add some error trapping to it if you think that the "Patrol->" line may not exist sometimes.

Something like:


If arrpassword = "" Then
wscript.echo "No password found"
wscript.quit
end if


Toss that in before the arrpassword(1) call, and it will exit the script and let you know that it cannot find the search string.
Answered 08/14/2009 by: Jsaylor
Second Degree Blue Belt

Please log in to comment
Answer this question or Comment on this question for clarity