Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Get User Variable from Windows


Recommended Posts

Hi!

Have a new good Year!

Have you just tried Mode 0 or any of the other up to 9 to see if there are any other output you can use ?

In the MP reference for 2018 on page 1894 it is documentation of it, I am not sure if It is allowed to share the pdf.

From the documentation:

The General form is:
S= sysinfo(result. mode)
Where
s   
a string variable that stores the user name / data

result  
integer variable that indicates whether or not the function was successful: 1 if the function was successful, otherwise 0

mode
a number or numeric variable that indicates the format in which you want the user data returned. Valid values are from 0-9

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

The function is essentially a wrapper for the Windows WINAPI function GetUserNameEx.
the different funtion states present the user name in a variety of different formats: these different formats correspond to the
EXTENDED_NAME_FORMAT enumerations defined in the WINAPI.

the following illustrates the output from each of the different modes. 
the sample output assumes the user name is John R. Martin, working for a company called ACME, with network domain ACME.COM

------------
Sysinfo ( ) function states

ssys_un = sysinfo(result, 0 should get you NameUnknown - Sample output: None
ssys_un = sysinfo(result, 1 should get you NameFullyQualifiedDN - Sample output: CN= John Martin, CN=users, DC=ACME, DC=com

ssys_un = sysinfo(result, 2 should get you NameSamCompatible - sample output ACME\JRM

ssys_un = sysinfo(result, 3 should give you NameDisplay - sample output John Martin
ssys_un = sysinfo(result, 4 should give you NameUniqueID - sample output {2afe5c63-8360-4030-b704-2c92e46c01cc}
ssys_un = sysinfo(result, 5 should give you NameCanonical - sample output ACME.COM/Users/John Martin
ssys_un = sysinfo(result, 6 should give you NameUserPrincipal - sample output [email protected]

ssys_un = sysinfo(result, 7 should give you NameCanonicalEx - sample output ACME.COM

                                                                                                                                          John Martin

ssys_un = sysinfo(result, 8 should give you NameServicePrincipal - sample output www/[email protected]

ssys_un = sysinfo(result, 9 should give you NameDnsDomain - sample output ACME.COM\JRM

 

Example :

sresult : ""

result : 0

pheader$     #Call before start of file

             "%", e$

              sresult=sysinfo(result,3)

              sopen_prn, "Posted by: ", sresult, sclose_prn, e$

 

-Edited with example and some text changes

 

 

 

HTH

G

Edited by geirsj
  • Like 1
Link to comment
Share on other sites
7 minutes ago, C^Millman said:

Here is what I got;

C:\>whoami /fqdn
ERROR: Unable to get Fully Qualified Distinguished Name (FQDN) as the current
       logged-on user is not a domain user.

That is what I would expect to see from Jeremy. That is why he is only getting the output for mode 2, IMO.

Then, the only way would be to parse the user name out of the local SAM name, or create a domain controller to handle naming conventions.

Edit: or to join an existing domain.

Link to comment
Share on other sites

On Mastercam forum a reply mentioning just nr 2 was option when you was not a member of a domain. also suggested string function like brksps to get

the username only to break to only the letters you need, will probably work if the computername always are the same, but not a robust solution he mentioned. 

see the thread post on Mastercam.

http://forum.mastercam.com/Topic24184.aspx

G

Link to comment
Share on other sites

I do get the samething as Ron for the FQDN.  However, I am a member of a domain which is weird, it's profab.local or something.  The only way I can see it is to log out and log in.  When I goto a cmd and use echo %userdomain% I only get my desktop name again.image.thumb.png.4fab19addcde09a23eeea932fb181ffd.png

Any way, is there a way in MP to parse only after a certain character as in Python?  I've been using Python so much lately I can't really get it out of my head to think in anything else.  Stupid Android app addiction.  I want to use this logic for every post that way any one who uses it will put their name in the post with out storing a local pst file just for them.

Link to comment
Share on other sites

All you see with returning the userdomain  environment variable is the NETBIOS domain name.

Check the %userdnsdomain% to see the DNS domain. This will show you the fqdn suffix.

The mode 2 "NameSamCompatible" result in the MP query is for backwards compatibility to NT4.0, Win 95/98 environments.

The fact that mode 9 "NameDnsDomain" doesn't return tells me there is an issue with the top level domain suffix, or you are really in a workgroup, not domain.

You can go into control panel -> System and see the Domain and suffix as it is connected.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...