•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 397,800 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,416 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser:
Views: 4627 | Replies: 10
![]() |
•
•
Join Date: Jul 2006
Posts: 16
Reputation:
Rep Power: 3
Solved Threads: 0
Hello,
I need help. I have been searching the web to try and find to somehow add vbscript in my visual basic application. I'm not sure how to go by doing that.
What I'm really trying to do is to use visual basic as a GUI and then use vbscript to add a user to the active directory. I saw that you could use a script engine in visual basic but that hasn't been working for me.
HELP!! PLEASE!!!:eek:
I need help. I have been searching the web to try and find to somehow add vbscript in my visual basic application. I'm not sure how to go by doing that.
What I'm really trying to do is to use visual basic as a GUI and then use vbscript to add a user to the active directory. I saw that you could use a script engine in visual basic but that hasn't been working for me.
HELP!! PLEASE!!!:eek:
•
•
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation:
Rep Power: 7
Solved Threads: 107
You should be able to use createobject, and create the object in question.... for example:
Which should create the WScript Shell object, and then launch it's "run" method to spawn notepad...
dim wsh
Set wsh = CreateObject("WScript.Shell")
wsh.run "c:\windows\notepad.exe", 1, 0•
•
Join Date: Jul 2006
Posts: 16
Reputation:
Rep Power: 3
Solved Threads: 0
Ok,
This helped me get a start on this. So this is what I have so far. I have a form in Visual Basic which calls this:
And then under the folder Scripts i have this for my vbscript
This all works fine, but what's say I wanted to replace "My" with my name. I would have a textbox on my form and then when I click on the button it would send what I entered into the text box infront of " very first script." Is that too much to ask?
If my spelling/grammar is not right it is because I'm slowing loosing blood from my thumb. ( Potato peeling accident )
This helped me get a start on this. So this is what I have so far. I have a form in Visual Basic which calls this:
Private Sub btnClickMe_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClickMe.Click
Dim wsh
wsh = CreateObject("WScript.Shell")
wsh.run("C:\Scripts\test.vbs", 1, 0)
End SubAnd then under the folder Scripts i have this for my vbscript
Wscript.echo "My very first script."
This all works fine, but what's say I wanted to replace "My" with my name. I would have a textbox on my form and then when I click on the button it would send what I entered into the text box infront of " very first script." Is that too much to ask?

If my spelling/grammar is not right it is because I'm slowing loosing blood from my thumb. ( Potato peeling accident )
•
•
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation:
Rep Power: 7
Solved Threads: 107
Yikes on the thumb....
Firstly, I want it to be known clearly that you are NOT using Visual Basic.... the used the same name, but it's actually .NET or express, but not legacy VB. The Forum that you are posting in, is for Visual Basic from 6 and below.... you are using .NET.
Your question, however, is related more to the concept of programming than to a specific language, so I'm not going to move the thread. I don't remember exactly if .NET's textboxes use the .text property, or the .value property, but I'll post code for both. One problem that you are going to face is the fact that the script file, IS NOT part of your program, which means you will either have to pass it parameters, OR you'll have to set an option somewhere that the script reads when it runs.
The two ways are basically like this, to pass the parameter:
you would set the vbscript file up to read whatever is passed it on the command line, just like if you click start, go to run, and type in: notepad hello.txt you'll see notepad do something out of the ordinary.... if hello.txt does not exist, notepad will ask you if you want to create a new file. You can make your VBScript program take parameters also, so you could call it with something like:
myscript.vbs jerry
and then it would use jerry as the input to display in the echo command.
The other method, would be to have the VB.Net Program write a value somewhere, like in a file, or in the registry, and then make the script program actually read that value from the file or registry, and act accordingly....
Firstly, I want it to be known clearly that you are NOT using Visual Basic.... the used the same name, but it's actually .NET or express, but not legacy VB. The Forum that you are posting in, is for Visual Basic from 6 and below.... you are using .NET.
Your question, however, is related more to the concept of programming than to a specific language, so I'm not going to move the thread. I don't remember exactly if .NET's textboxes use the .text property, or the .value property, but I'll post code for both. One problem that you are going to face is the fact that the script file, IS NOT part of your program, which means you will either have to pass it parameters, OR you'll have to set an option somewhere that the script reads when it runs.
The two ways are basically like this, to pass the parameter:
you would set the vbscript file up to read whatever is passed it on the command line, just like if you click start, go to run, and type in: notepad hello.txt you'll see notepad do something out of the ordinary.... if hello.txt does not exist, notepad will ask you if you want to create a new file. You can make your VBScript program take parameters also, so you could call it with something like:
myscript.vbs jerry
and then it would use jerry as the input to display in the echo command.
The other method, would be to have the VB.Net Program write a value somewhere, like in a file, or in the registry, and then make the script program actually read that value from the file or registry, and act accordingly....
•
•
•
•
Originally Posted by Comatose
Firstly, I want it to be known clearly that you are NOT using Visual Basic.... the used the same name, but it's actually .NET or express, but not legacy VB.
I'm also curious why in a VB application someone would want to use VBScript? Why not just use VB?
•
•
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation:
Rep Power: 7
Solved Threads: 107
Private Sub btnClickMe_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClickMe.Click is a declaration type that is only acceptable in a .NET layout. The parameters passed are system event objects (system.object, system.eventargs) which doesn't exist in legacy VB, and beyond that, the "handles" keyword for the event doesn't exist in legacy VB. Those are strictly used in .NET or VB Express (which is actually .NET also).As for his motivation..... who knows, maybe he's calling a script that someone else made, and doesn't want to try to port the entire thing..... we will only know if he chooses to answer that question.
Last edited by Comatose : Aug 5th, 2006 at 9:17 am.
•
•
Join Date: Jul 2006
Posts: 16
Reputation:
Rep Power: 3
Solved Threads: 0
Well that sure answers a lot of unasked questions. I knew something didn't seem right when I downloaded VB express. I only know how to programing in VB 6.0 not .Net.
I'm trying to program in VB 6, but I didn't want to purchase it just to do this one project. I would like it to just do it all in VB and not use VBscript cause that is just starting to confuse me cause VB 6, .Net, and VBscript almost look the same to me. My questions is could I control the active directory with VB? If so is there any good material about this on the internet?
For example add a user and delete a user. Even move a user from one OU to another OU.
Thanks :cheesy:
I'm trying to program in VB 6, but I didn't want to purchase it just to do this one project. I would like it to just do it all in VB and not use VBscript cause that is just starting to confuse me cause VB 6, .Net, and VBscript almost look the same to me. My questions is could I control the active directory with VB? If so is there any good material about this on the internet?
For example add a user and delete a user. Even move a user from one OU to another OU.
Thanks :cheesy:
•
•
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation:
Rep Power: 7
Solved Threads: 107
•
•
Join Date: Jul 2006
Posts: 16
Reputation:
Rep Power: 3
Solved Threads: 0
Well the thing is that I haven't coded anything yet. I was just doing some research before I start coding and find out that I wasted all my time in VBscript or Visual Basic, but this is what I want to do:
1. The user will enter and select all appropriate fields.
2. The user will select the “ADD USER” button.
3. A data validation check will be run to ensure that all fields have data in them. If any field is missing data the program should terminate with an error telling the user that “One or more fields is missing data.” And then bring them back to the main screen to fix the error and try again.
4. The program will use the AD Admin credentials supplied to add the user to the selected domain “SELECT THE DC FOR NEW USER” with a standard user profile and the “Description field” being filled with what the User had entered in the “ENTER A DESCRIPTION FOR THE NEW USER” field.
5. The program will then add the newly created user to all the groups that were selected in the “SELECT GROUPS FOR USER” area.
6. The program will then assign a password of “ecare01” that is a Zero not an O. Also, the option of “Force user to change password at next login” will be enabled.
7. Using the E-mail admin credentials supplied the program will then log into the appropriate mail server. This will be determined by the domain selected.
8. At the end of the script. Any errors reported during the creation of the user will be output to the screen with descriptive error messages.
9. The program will bring the user back to the beginning.
1. The user will enter and select all appropriate fields.
2. The user will select the “ADD USER” button.
3. A data validation check will be run to ensure that all fields have data in them. If any field is missing data the program should terminate with an error telling the user that “One or more fields is missing data.” And then bring them back to the main screen to fix the error and try again.
4. The program will use the AD Admin credentials supplied to add the user to the selected domain “SELECT THE DC FOR NEW USER” with a standard user profile and the “Description field” being filled with what the User had entered in the “ENTER A DESCRIPTION FOR THE NEW USER” field.
5. The program will then add the newly created user to all the groups that were selected in the “SELECT GROUPS FOR USER” area.
6. The program will then assign a password of “ecare01” that is a Zero not an O. Also, the option of “Force user to change password at next login” will be enabled.
7. Using the E-mail admin credentials supplied the program will then log into the appropriate mail server. This will be determined by the domain selected.
8. At the end of the script. Any errors reported during the creation of the user will be output to the screen with descriptive error messages.
9. The program will bring the user back to the beginning.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Visual Basic 4 / 5 / 6 Marketplace
- mySQL + visual basic 6 (MySQL)
- Encrypting a Visual Basic application (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Change password for admin
- Next Thread: Randomize generate massive user name database?



Linear Mode