Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need help replacing an area of a existing vbscript base on a user in

Status
Not open for further replies.

Alienskull

Programmer
Jan 8, 2012
6
0
0
US
Basically I'm trying to create a vbscript that ask a user for their name. Once I get their name I would like to transfer the name like "todd" to another premade vbs script, to a specific location in that script.
example:

blah, blah blah
ipf.Value = "Todd"

So a input box come up asking for a user to enter their name. The name is then transfered to a specific area of a premade vbs script that tell it what to do with "Todd"
whatever name any user enter is what I would like to replace that area where Todd. Has to be that specific area of a vbscript. Thanks.
 
can you modify the premade script? if so, look into passing the premade script an argument using wscript.arguments

Code:
set objArgs = wscript.arguments
strName = objArgs(0)
ipf.Value = strName

-Geates

"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Thanks for quick responds Geates but I'm not sure what you mean, I don't even have an inputbox yet. I can edit the script but I'm not sure where to put the code you mention.
 
This is what I have now. My main problem is creating an input box that will ask for username and password. Once I get this I want to be able to change the fields "myusername" and "mypassword" with this result. Then I will have a new script that I can run with the user's info. This is what I have:

DIM IE
DIM ipf

Set IE = CreateObject("InternetExplorer.Application")
IE.navigate "IE.Visible = True

While IE.Busy
WScript.Sleep 50
Wend



Set ipf = IE.document.all.Item("ctl00$ContentHolder1$txtUserId")
ipf.Value = "myusername"

Set ipf = IE.document.all.Item("ctl00$ContentHolder1$txtPassword")
ipf.Value = "mypassword"


While IE.Busy
WScript.Sleep 2000
Wend

Set ipf = IE.document.all.Item("ctl00$ContentHolder1$btnLogin")
ipf.Click 'click the ctl00$ContentHolder1$btnLogin button



While IE.Busy
WScript.Sleep 2000
Wend
IE.navigate "
 
Will there be names other than Todd? If not, why not just change the script to Todd?

-Geates

"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
The InputBox function will let you input the fields you want.

Geates' code could be used to retrieve command line parameters sent into the "premade" vbscript.

But it seems simpler to just modify the premade script, rather than deal with two scripts.

Code:
Dim sUsername, sPassword
sUsername = InputBox("Please enter the username:") 
sPassword = InputBox("Please enter the password:")

.......

Set ipf = IE.document.all.Item("ctl00$ContentHolder1$txtUserId") 
        ipf.Value = sUsername  

Set ipf = IE.document.all.Item("ctl00$ContentHolder1$txtPassword") 
        ipf.Value = sPassword
 
Geates, the username and password will change each time someone enters them in the box. Todd today might be James tomorrow.

Guitarzan, I tried what you suggest but the reason I want 2 scripts is because the user won't need to login again once their name is stored in the second script. So all they would need to do is click on the second script and they should automatically be logged in. Thanks for the above script though. It's very close to what I'm trying to do.

You see the script that I posted would be the second script. But I need another script to bring up a username/password box and transfer the input to my second script.
 
Guess I totally misread what you want, Alienskull. So you want the Script1 to ask for a username and password, and then MODIFY THE CONTENTS of Script2, basically hardcoding the username and password into Script2???

This is a rather non-standard way of doing this... More standard and simpler would be to have the user enter their username / password each time. Or, store the username / password (encrypted) for re-use later (though I don't have a good source for how to do that).

If you really want to modify the contents of Script2, we can help, but it is fraught with possible problems.
 
Is their any other way of doing this such as hta script. I really need to do the hardcode, or if you know of any other way. Thanks.
 
How about saving the name and encrypted password to the registry? Simple with wsh/vbs.
guitarzan' s script could be modified to do this and we are back with a 1 script solution. Are you able to modify the original script?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top