Hi All,
Need to execute net user command using CMD through macro. the account name is being captured in excel and then using macro need to execute below command:
net user "username from excel" /do
here is my code below and appreciate your help:
Sub Button3_Click()
Dim wb1 As Workbook, wb2 As Workbook, Wb3 As Long, wb4 As String, wb5 As Long
Set wb1 = ThisWorkbook
Wb3 = Range("C3").Value
wb4 = "moe@" & Wb3
Set wb2 = Workbooks.Open("C:\Bulk\Source.csv")
wb1.Sheets("Master").Range("C25").Copy
wb2.Sheets("source").Range("A2").PasteSpecial xlPasteValues
Range("B2") = wb4
wb5 = Range("C25").Value
Shell ("cmd.exe /k net user" & Range("C25") & "/do")
ActiveWorkbook.Save
ActiveWorkbook.Close True
End Sub
Need to execute net user command using CMD through macro. the account name is being captured in excel and then using macro need to execute below command:
net user "username from excel" /do
here is my code below and appreciate your help:
Sub Button3_Click()
Dim wb1 As Workbook, wb2 As Workbook, Wb3 As Long, wb4 As String, wb5 As Long
Set wb1 = ThisWorkbook
Wb3 = Range("C3").Value
wb4 = "moe@" & Wb3
Set wb2 = Workbooks.Open("C:\Bulk\Source.csv")
wb1.Sheets("Master").Range("C25").Copy
wb2.Sheets("source").Range("A2").PasteSpecial xlPasteValues
Range("B2") = wb4
wb5 = Range("C25").Value
Shell ("cmd.exe /k net user" & Range("C25") & "/do")
ActiveWorkbook.Save
ActiveWorkbook.Close True
End Sub