By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,101 Members | 1,387 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,101 IT Pros & Developers. It's quick & easy.

Return any character positions within a string

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

net use u: \\Myserver\Folder45 Cyrus024 /User:NA\cyrus.t.andrews
net use v: \\Myserver\Folder3645 Cyrus024 /User:NA\cyrus.t.andrews
net use x: \\Myserver\Folder32645 Cyrus024 /User:NA\cyrus.t.andrews
net use y: \\Myserver\Folder995 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))
Mar 21 '07 #1
Share this Question
Share on Google+
1 Reply


100+
P: 149
I have a .bat file that has the following links with network passwords.

net use u: \\Myserver\Folder45 Cyrus024 /User:NA\cyrus.t.andrews
net use v: \\Myserver\Folder3645 Cyrus024 /User:NA\cyrus.t.andrews
net use x: \\Myserver\Folder32645 Cyrus024 /User:NA\cyrus.t.andrews
net use y: \\Myserver\Folder995 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
Mar 22 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.