I am trying to get a program to work that starts robocopy.exe as a process, the problem I am running into is with the username used in the operation. it seems that I cannot use this program on more then one computer.
With trial and error, I have gotten the process to work in a command line runas command with the /netonly flag. but I am unsure how to do something similar with the function i have in my code.
Here is my code:
Dim conConnection As New ADODB.Connection
Dim cmdCommand As New ADODB.Command
Dim rstRecordSet As New ADODB.Recordset
conConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
conConnection.CursorLocation = ADODB.CursorLocationEnum.adUseClient
.ActiveConnection = conConnection
.CommandText = "SELECT * FROM TABLE;"
.CommandType = ADODB.CommandTypeEnum.adCmdText
.CursorType = ADODB.CursorTypeEnum.adOpenStatic
.CursorLocation = ADODB.CursorLocationEnum.adUseClient
.LockType = ADODB.LockTypeEnum.adLockOptimistic
If rstRecordSet.RecordCount <> 0 Then
Dim file As String
file = "C:\robocopy.exe"
Dim args As String
args = "\\mje-imtmifile02\500div\Job_Files\5XXXXXXX-Template-New-Folders " & rstRecordSet.Fields(0).Value & " *.* /copyall /mir"
Dim username As String
username = "USER"
Dim pass As SecureString
pass = Secure()
Dim Dom As String
Dom = "DOMAIN"
Process.Start(file, args, username, pass, Dom)
Public Function Start(fileName As String, arguments As String, userName As String, password As SecureString, domain As String) As Process
Public Function Secure() As SecureString
Dim pass As String
pass = "PASSWORD"
Dim str As New SecureString
For x As Integer = 0 To pass.Length - 1
The issue seems to be with my Start() function. It seems to have to do with running a user across multiple computers.
any help would be appreciated. or an alternative solution.