Question VBScript works but VB.NET code does not

KeeNuM23

New member
Joined
Apr 4, 2011
Messages
2
Programming Experience
Beginner
I'm working on a program that will add a user on the domain to a particular PC's local admin group.

Here's the code from VBScript, that works:

VB.NET:
Dim FSO

Set FSO = CreateObject("Scripting.FileSystemObject")
strComputer = "PC NAME HERE"
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators")
Set objUser = GetObject("WinNT://DOMAIN/USERNAME")
objGroup.Add(objUser.ADsPath)
wscript.echo "Local Admin Added."
And here is the code that I'm using in VB.NET:

VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim FSO
        FSO = CreateObject("Scripting.FileSystemObject")
        Dim strComputer = "PC NAME HERE"
        Dim objGroup = GetObject("WinNT://" & strComputer & "/Administrators")
        Dim objUser = GetObject("WinNT://DOMAIN/USERNAME HERE")
        objGroup.Add(objUser.ADsPath)
    End Sub
When I click "Button1", no changes are made :(

Any help would be very much appreciated! Thanks.
 
That's a toughy! Errm.. first of all i'd suggest going through with a break point, and making sure every step is doing what you want it too ? Second i'd say you make sure you've got your directories right, and that you're not looking at the wrong place? If none of those work, then im stumped.. That really is a very strange problem.
 

Latest posts

Back
Top