P
Pierced Indie Rock Band
I am trying to run net user in a .bat file from MS Access.
For some reason I get stuck on the Shell line. If I run the .bat file
manually, it works perfectly.
How can I get this to work?
Code
Private Sub Command0_Click()
Dim dbs As Database
Dim rst As DAO.Recordset
Dim f
Dim userID As String
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("qryData")
rst.MoveFirst
Do Until rst.EOF
userID = rst![Exchange Alias]
Open "C:\UserAccesReport\GetUser.bat" For Output As #1
Print #1, "net user " & userID & " /domain" >C:\Results\" & userID
& ".txt"
Close #1 ' Close file.
Shell "C:\UserAccesReport\GetUser.bat"
rst.MoveNext
Loop
MsgBox "Complete"
End Sub
For some reason I get stuck on the Shell line. If I run the .bat file
manually, it works perfectly.
How can I get this to work?
Code
Private Sub Command0_Click()
Dim dbs As Database
Dim rst As DAO.Recordset
Dim f
Dim userID As String
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("qryData")
rst.MoveFirst
Do Until rst.EOF
userID = rst![Exchange Alias]
Open "C:\UserAccesReport\GetUser.bat" For Output As #1
Print #1, "net user " & userID & " /domain" >C:\Results\" & userID
& ".txt"
Close #1 ' Close file.
Shell "C:\UserAccesReport\GetUser.bat"
rst.MoveNext
Loop
MsgBox "Complete"
End Sub