Re: Pass Variable to external VBS
- From: mrmwalter@xxxxxxxxxxx
- Date: Sun, 9 Dec 2007 04:33:59 -0800 (PST)
Hi Larry,
Thanks for taking time to reply.
Good question, the only reason I was going to pass it to vbs is
because I have more knowledge of VBS. And as I need a GUI, I though
Visual Basic would be easiest to create the form.
If I could figure out the code to add user to local domain in Visual
Basic, I would keep it all in Visual Basic.
But if I insert the code:
strComputer = "project"
Set objGroup = GetObject("WinNT://" & strComputer & "/
Administrators")
Set objUser = GetObject("WinNT://offline/abc")
objGroup.Add(objUser.ADsPath)
msgbox "done."
into the form - it doesn't work.
Sorry - I am new to Visual Basic.
Someone else has mentioned the way to do it may be to add the user
name to the string in my VBA procedure, you will add the user name to
the string that
I use to start the process . That is:
command: p = Process.Start("C:\VB\Test\BasicUsername.vbs" & " " &
TextBox.Text)
2. In the script, I use the WshArguments object to retrieve the
parameters passed to the script.
Set objArgs = WScript.Arguments
Set objUser = GetObject("WinNT://offline/" & opbjArgs(0))
For some reason, I am still having issues with passing whatever is
typed in the text box to the vbs.
To make this as simple as possible, I have recreated from scratch. On
my Visual Basic form, I just have a text box and a button.
On the vbs, I just want a MessageBox to display the UserName that was
entered on the text box.
Here is the Visual Basic Form:
Public Class Form1
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim p As Process
p = Process.Start("C:\VB\Test\PassVar.vbs" & " " & TextBox1.Text)
p.WaitForExit()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
End Class
Here is the VBS (I've rem'd 2 lines out), where I just want it to
display the username that was entered:
Set objArgs = WScript.Arguments
'Set objUser = GetObject(objArgs(0))
'Set objUser = GetObject("WinNT://offline/" & objArgs(0))
MsgBox (objArgs)
Can you see where I'm going wrong? I get an error saying file doesn't
exist, but if I take the "" & " " & TextBox1.Text" away, it does
launch the VBS, which proves the vbs does exist.
I hope you can help me?!
Thanks again.
.
- References:
- Pass Variable to external VBS
- From: mrmwalter
- Re: Pass Variable to external VBS
- From: heintz.larry@xxxxxxxxx
- Pass Variable to external VBS
- Prev by Date: Re: problem with date conversion
- Next by Date: Re: StreamWriter Problem (OT)
- Previous by thread: Re: Pass Variable to external VBS
- Next by thread: Adding a Help file
- Index(es):