Return any character positions within a string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kaptandrews
    New Member
    • Mar 2007
    • 1

    Return any character positions within a string

    I have a .bat file that has the following links with network passwords.

    net use u: \\Myserver\Fold er45 Cyrus024 /User:NA\cyrus.t .andrews
    net use v: \\Myserver\Fold er3645 Cyrus024 /User:NA\cyrus.t .andrews
    net use x: \\Myserver\Fold er32645 Cyrus024 /User:NA\cyrus.t .andrews
    net use y: \\Myserver\Fold er995 Cyrus024 /User:NA\cyrus.t .andrews

    I want the code to pull the password "Cyrus24" so that it can be replaced. I want to be able to do this every 30 days when the password expires. Problem is I have to define the string exactly in order to change the characters I want to change. How can I get the code to pull any 8 characters that proceed "^/User:NA\cyrus.t .andrews"?

    Here is what I have tried:

    '--get text to replace and new text.
    s1 = inputbox ("Enter text to be replaced.", "What to replace?", Right/User:NA\cyrus.t .andrews ",8))
  • ansumansahu
    New Member
    • Mar 2007
    • 149

    #2
    Originally posted by Kaptandrews
    I have a .bat file that has the following links with network passwords.

    net use u: \\Myserver\Fold er45 Cyrus024 /User:NA\cyrus.t .andrews
    net use v: \\Myserver\Fold er3645 Cyrus024 /User:NA\cyrus.t .andrews
    net use x: \\Myserver\Fold er32645 Cyrus024 /User:NA\cyrus.t .andrews
    net use y: \\Myserver\Fold er995 Cyrus024 /User:NA\cyrus.t .andrews

    I want the code to pull the password "Cyrus24" so that it can be replaced. I want to be able to do this every 30 days when the password expires. Problem is I have to define the string exactly in order to change the characters I want to change. How can I get the code to pull any 8 characters that proceed "^/User:NA\cyrus.t .andrews"?

    Here is what I have tried:

    '--get text to replace and new text.
    s1 = inputbox ("Enter text to be replaced.", "What to replace?", Right/User:NA\cyrus.t .andrews ",8))
    We can use the Instr function to retrive the character position.

    InStr returns the first occurrence of a string inside another string.

    InStr([start,] string1, string2 [, compare])

    thanks
    ansuman sahu

    Comment

    Working...