[求助]判断机器名,执行文件
我想PC1-PC500号机执行d:\a.exe
PC501-PC1000号执行d:\b.exe
怎么写
我想PC1-PC500号机执行d:\a.exe
PC501-PC1000号执行d:\b.exe
怎么写
程序运行,先判断这台机的机器名
如果是pc1至pc500就执行d:\a.exe
如果机器名是pc501至pc1000就执行d:\b.exe
我试过这样写,不行...
Private Sub Form_Load()
a = VBA.Environ("computername")
For i = 1 To 500
Next
If a = pc(i) Then
Shell "d:\a.exe"
Else
Shell "d:\b.exe"
End If
End Sub
Private Sub Form_Load()
Dim cpname As String
Dim num As Long
On Error GoTo errline
cpname = Environ("computername")
num = CLng(Right(cpname, Len(cpname) - 2))
If num >= 1 And num <= 500 Then
Shell "d:\a.exe"
ElseIf num >= 501 And num <= 1000 Then
Shell "d:\b.exe"
End If
Exit Sub
errline:
End Sub