hexagon logo

getting computer name

Anyone out there know how to do this either in PC-dmis itself or in a script?
Parents
  • Maybe this could help.

    ' Get various info from WScript.Network and add it to
    ' a PCDMIS partprogram. If the variable exists, it changes
    ' (updates) the variable to the currently logged in user.
    '
    ' Save as .bas and call it, from within the program or
    ' via an icon on your PCDMIS toolbar.
    '
    ' Tested on v2010 MR1
    '
    ' vpt.se 2010
    '
    
    Dim objNet
    Dim uname, varname
    Dim PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands, PCDCommand
    Dim cnt as integer
    Dim found as boolean
    
    Sub Main
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPartPrograms = PCDApp.PartPrograms
    Set PCDPartProgram = PCDApp.ActivePartProgram
    Set PCDCommands = PCDPartProgram.Commands
    
    Set objNet = CreateObject("WScript.NetWork") 
    'objNet.ComputerName = computername
    'objNet.UserDomain = domain
    'objnet.UserName = logged on user
    
    found = false
    uname = """" & objNet.UserName & """"
    varname = "V1" ' change this to reflect "your" variablename
    	
    for cnt = 1 to PCDCommands.Count
      set PCDCommand = PCDCommands.Item(cnt)
      if ((PCDCommand.Type = 195) and (varname = PCDCommand.GetText(DEST_EXPR, 0))) Then
        retval = PCDCommand.PutText(uname, SRC_EXPR, 0)
        found = true
      end if
    next
    
    if not found then
      Set PCDCommand = PCDCommands.Add(195, True) 
      PCDCommand.marked = true
      retval = PCDCommand.PutText(varname, DEST_EXPR, 0) 
      retval = PCDCommand.PutText(uname, SRC_EXPR, 0)
    end if
    
    'Cleanup
    Set PCDCommands = Nothing
    Set PCDPartPrograms = Nothing
    Set PCDPartProgram = Nothing
    Set PCDApp = Nothing
    Set objNet = Nothing                    
    End Sub
Reply
  • Maybe this could help.

    ' Get various info from WScript.Network and add it to
    ' a PCDMIS partprogram. If the variable exists, it changes
    ' (updates) the variable to the currently logged in user.
    '
    ' Save as .bas and call it, from within the program or
    ' via an icon on your PCDMIS toolbar.
    '
    ' Tested on v2010 MR1
    '
    ' vpt.se 2010
    '
    
    Dim objNet
    Dim uname, varname
    Dim PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands, PCDCommand
    Dim cnt as integer
    Dim found as boolean
    
    Sub Main
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPartPrograms = PCDApp.PartPrograms
    Set PCDPartProgram = PCDApp.ActivePartProgram
    Set PCDCommands = PCDPartProgram.Commands
    
    Set objNet = CreateObject("WScript.NetWork") 
    'objNet.ComputerName = computername
    'objNet.UserDomain = domain
    'objnet.UserName = logged on user
    
    found = false
    uname = """" & objNet.UserName & """"
    varname = "V1" ' change this to reflect "your" variablename
    	
    for cnt = 1 to PCDCommands.Count
      set PCDCommand = PCDCommands.Item(cnt)
      if ((PCDCommand.Type = 195) and (varname = PCDCommand.GetText(DEST_EXPR, 0))) Then
        retval = PCDCommand.PutText(uname, SRC_EXPR, 0)
        found = true
      end if
    next
    
    if not found then
      Set PCDCommand = PCDCommands.Add(195, True) 
      PCDCommand.marked = true
      retval = PCDCommand.PutText(varname, DEST_EXPR, 0) 
      retval = PCDCommand.PutText(uname, SRC_EXPR, 0)
    end if
    
    'Cleanup
    Set PCDCommands = Nothing
    Set PCDPartPrograms = Nothing
    Set PCDPartProgram = Nothing
    Set PCDApp = Nothing
    Set objNet = Nothing                    
    End Sub
Children
No Data