Help with moving batch to VB application

ryan72

New member
Joined
Mar 11, 2009
Messages
2
Programming Experience
Beginner
I've created a batch file on our domain controller to export users based on the OU they are in.

VB.NET:
@ECHO OFF
ECHO This tool will export all users in the chosen Active Directory OU.
ECHO.
ECHO The file will be saved to your desktop.
ECHO.
SET CHOICE=
SET /P Choice=Client ID? 
csvde -f C:\Users\%username%\Desktop\AD_%CHOICE%.csv -r sAMAccountName=%CHOICE%* -l "sAMAccountName"

I'd like to make this into a simple one form application that our admins can have access to. The problem is, every attempt I have made (I don't know much, so it's editing existing code I've found online) has failed.

VB.NET:
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Process.Start("C:\Windows\system32\csvde.exe -f C:\Users\%username%\Desktop\AD_{0}.csv -r sAMAccountName={0}* -l sAMAccountName", 0.txtClientID.Text)
    End Sub
End Class

The form design is only a text box (txtClientID) and a Go button.

Any assistance would be appreciated.
 
Last edited:
could you write the batch commands to a .BAT file and then execute that file?

VB.NET:
''  write your batch info to a file and fill variable "myBatchFileName"
dim myBatchFileName as string="C:\batchfilename.bat"
dim pr as new process()
pr.StartInfo.FileName=myBatchFileName
pr.start()
 
Back
Top