call procedure

  • Thread starter Thread starter Kenneth H. Young
  • Start date Start date
K

Kenneth H. Young

I would like to call a command prompt with the following variables:
nbtstat -a computername but can't get the syntax right.

Dim stAppName, stPCName As String
stPCName = Me.DNSName
stAppName = "C:\Windows\System32\cmd.exe nbtstat -a stPCName"


Thanks in advance!
 
Hi Kenneth,

Thanks for your post. If I understand correctly that you want to get the
following syntax right.

Dim stAppName, stPCName As String
stPCName = Me.DNSName
stAppName = "C:\Windows\System32\cmd.exe nbtstat -a stPCName"

Based on my research, because stPCName is a string variable, you cannot use
it directly in string and assign it to stAppName variable. Please try the
following codes and check to see if it works on your side.

stAppName = "C:\Windows\System32\cmd.exe nbtstat -a " & stPCName

Please feel free to post in the group if this solves your problem or if you
would like further assistance on this issue.

Regards,

Michael Shao
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
I tried the string you suggested but that didn't work either. A command
prompt opens and that's it.

Private Sub Command330_Click()

On Error GoTo Err_Command330_Click

Dim stAppName, stPCName As String

stPCName = Me.DNSName

stAppName = "C:\Windows\System32\cmd.exe nbtstat -a" $ stPCName

Call Shell(stAppName, 1)


Exit_Command330_Click:

Exit Sub

Err_Command330_Click:

MsgBox Err.Description

Resume Exit_Command330_Click


End Sub



I then tried calling a command job 'nbt.cmd', but that comes back with an
error 'File Not Found':

------------------Command Job-------------------- c:\ cd \ nbtstat -a %1
pause End

-------------------------------------------------

Private Sub Command330_Click()

On Error GoTo Err_Command330_Click

Dim stAppName, stPCName As String

stPCName = Me.DNSName

stAppName = "C:\Program Files\NCSTSHI\nbt.cmd" & stPCName

Call Shell(stAppName, 1)


Exit_Command330_Click:

Exit Sub

Err_Command330_Click:

MsgBox Err.Description

Resume Exit_Command330_Click


End Sub

I then tried it without the '& stPCName', this opens a command prompt and
display nbtstat help because no pc name was provided.

How would you go about this?



Thanks!
 
Hi Kenneth,

Thanks for your feedback. Please try the following codes on your side.

Dim stAppName, stPCName As Variant
stPCName = "<PCName>"
stAppName = "cmd.exe /c nbtstat -a " & stPCName
Call Shell(stAppName, 1)

Note: <PCName> is the Computer name which you want to specify.

It works on my side and please let me know if it solved your problem.

I am looking forward to hearing from you soon.

Best wishes,

Michael Shao
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Kenneth,

How is the issue going on your side? Let us know if you need further
assistance on this issue.

Regards,

Michael Shao
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top