cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
%3CLINGO-SUB%20id%3D%22lingo-sub-3464%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3Ecomputer%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3464%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EHi%20jmpers%2C%3CBR%20%2F%3E%3CBR%20%2F%3EI%20need%20to%20build%20an%20application%20in%20jmp%20for%20different%20users%2C%20meaning%20that%20different%20users%20will%20have%20different%20User%20Interface..%20(it%20is%20the%20same%20application)%20I%20was%20wondering%20if%20is%20there%20a%20way%20to%20get%20user%20profile%3F%20Let%20say%20computer%20name%2C%20user%20name%20or%20server%20name%20from%20jmp%20%3F%20Doing%20so%20I%20can%20decide%20which%20script%20to%20open%3CBR%20%2F%3E%3CBR%20%2F%3ETanks%3CBR%20%2F%3E%3CBR%20%2F%3Epniel%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-84899%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20computer%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-84899%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EFor%20Mac%20OS%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETry%20this%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EIf(%20Host%20is(%20%22Mac%22%20)%2Cusername%3DGet%20Environment%20Variable(%20%22USER%22%20)%3B%0A%20stamp%3D%22Test%20%22%7C%7Cusername%7C%7C%22%2C%20%22%7C%7Cchar(today())%3B%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-80209%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20computer%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80209%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EAwesome!%20thanks%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-80192%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20computer%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80192%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EYou%20can%20use%20a%20For()%20Loop%2C%20or%20you%20could%20do%20something%20like%20the%20below%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0Adt%20%3D%20Open(%20%22%24SAMPLE_DATA%2FConsumer%20Preferences.jmp%22%20)%3B%0A%0Auname%20%3D%20Get%20Environment%20Variable(%20%22COMPUTERNAME%22%20)%3B%0A%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%20%22User%22%2C%20character%2C%20set%20each%20value(%20uname%20)%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-80117%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20computer%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80117%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EIt%20works.But%20what%20if%20I%20have%2010%20rows%20and%20want%20to%20have%20uname%20ina%20ll%20rows%3F%3C%2FP%3E%3CP%3EDo%20I%20use%20a%20for%20loop%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-80054%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20computer%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80054%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EYou%20have%20to%20tell%20JMP%20which%20row%20in%20the%20data%20table%26nbsp%3Bfor%20column%20User%20you%20want%20to%20save%20the%20value%20to.%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Euname%20%3D%20Get%20Environment%20Variable(%20%22COMPUTERNAME%22%20)%3B%0Adt%3Auser%5B1%5D%20%3D%20uname%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EThe%20above%20would%20save%20the%20value%20of%20%22uname%22%20to%20row%201%20value%20for%20column%20%22user%22%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-80045%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20computer%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-80045%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EI%26nbsp%3Bneed%20to%20get%20the%20computer%20user%20name%20and%20store%20it%20in%20a%20column%20of%20a%20datatable.I%20am%20using%20following%20script%20-%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Euname%20%3D%20Get%20Environment%20Variable(%20%22COMPUTERNAME%22%20)%3B%3CBR%20%2F%3Edt%3Auser%20%3D%20uname%3B%3C%2FP%3E%3CP%3Ewhere%20dt%20is%20the%20data%20table%20and%20user%20is%20the%20name%20of%20the%20column.%3C%2FP%3E%3CP%3EBut%20I%20get%20the%20following%20error%20-%3C%2FP%3E%3CP%3E%22Cannot%20set%20value%20for%20the%20column%20'user'%20because%20the%20row%20number%20(-1)%20is%20not%20valid.%22%3C%2FP%3E%3CP%3ECan%20someone%20pls%20tell%20me%20what%20is%20wrong%20here%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3474%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20computer%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3474%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CP%3Ethanks%2C%20syntax%20in%20JMP12%20is%20actually%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EGet%20Environment%20Variable(%22Computername%22)%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3473%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20computer%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3473%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EI%20need%20something%20that%20can't%20be%20hacked%20by%20something%20as%20simple%20as%20setting%20the%20environment%20variable.%26nbsp%3B%20Thanks%20JohnP%20for%20both%20solutions!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3472%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20computer%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3472%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EJMP%2010%20supports%20this%20query%20directly%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EGet%20Enviromental%20Variable(%22Computername%22)%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EBest%2C%3C%2FP%3E%3CP%3E-Matt%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3471%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20computer%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3471%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EThe%20original%20post%20also%20asked%20about%20the%20computer%20name.%20To%20get%20the%20computer%20name%2C%20use%20Kernel32.dll%20and%20the%20method%20name%2C%20GetComputerNameA().%20So%20it%20will%20look%20like%20this%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%3D%20%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3ELoad%20DLL%3C%2FSPAN%3E(%20%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22Kernel32.dll%22%3C%2FSPAN%3E%20)%3B%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20DeclareFunction(%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22GetComputerNameA%22%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Convention(%20STDCALL%20)%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Alias%20(%20%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22GetComputerName%22%3C%2FSPAN%3E%20)%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E(%20AnsiString%2C%20%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22computername%22%3C%2FSPAN%3E%2C%20output%20)%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E(%20UInt64%2C%20%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22length%22%3C%2FSPAN%3E%2C%20update%20)%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Returns(%20UInt32%20)%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3Ename%20%3D%20%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22%3C%2FSPAN%3E%3B%3C%2FP%3E%3CP%3Eunlen%20%3D%20%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3Elength%3C%2FSPAN%3E(name)%3B%3C%2FP%3E%3CP%3Eresult%20%3D%20dll%20%26lt%3B%26lt%3B%20GetComputerName(name%2C%20unlen)%3B%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3Eshow%3C%2FSPAN%3E(name)%3B%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20UnloadDLL()%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EJohnP%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3470%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20computer%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3470%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EJohnP%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EThanks%20so%20much!%26nbsp%3B%20That's%20exactly%20what%20I'm%20looking%20for.%26nbsp%3B%20Can't%20mark%20this%20as%20the%20correct%20answer%20because%20I%20didn't%20start%20this%20thread.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20__jive_emoticon_name%3D%22cool%22%20__jive_macro_name%3D%22emoticon%22%20class%3D%22jive_macro%20jive_macro_emoticon%20jive_emote%22%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2F5.0.2%2Fimages%2Femoticons%2Fcool.gif%22%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3469%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20computer%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3469%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHere%20is%20some%20JSL%20that%20I%20wrote%20for%20getting%20the%20username%20from%20the%20system.%20This%20worked%20in%20JMP%2010%2C%20running%20on%20Windows%207.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%3D%20%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3ELoad%20DLL%3C%2FSPAN%3E(%20%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22mpr.dll%22%3C%2FSPAN%3E%20)%3B%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20DeclareFunction(%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22WNetGetUserA%22%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Convention(%20STDCALL%20)%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Alias%20(%20%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22GetUserName%22%3C%2FSPAN%3E%20)%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E(%20UInt8%2C%20%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22format%22%3C%2FSPAN%3E%2C%20input%20)%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E(%20AnsiString%2C%20%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22username%22%3C%2FSPAN%3E%2C%20output%20)%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E(%20UInt64%2C%20%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22length%22%3C%2FSPAN%3E%2C%20update%20)%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Returns(%20UInt32%20)%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3Eusername%20%3D%20%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22%3C%2FSPAN%3E%3B%3C%2FP%3E%3CP%3Eunlen%20%3D%20%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3Elength%3C%2FSPAN%3E(username)%3B%3C%2FP%3E%3CP%3Eresult%20%3D%20dll%20%26lt%3B%26lt%3B%20GetUserName(%3CSPAN%20style%3D%22color%3A%20%23008000%3B%22%3E0%3C%2FSPAN%3E%2C%20username%2C%20unlen)%3B%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3Eshow%3C%2FSPAN%3E(username)%3B%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20UnloadDLL()%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EFirst%2C%20you%20need%20to%20load%20the%20system%20DLL.%20I%20didn't%20have%20any%20luck%20with%20Advapi32.dll.%20But%20I%20found%20what%20I%20needed%20with%20mpr.dll.%20Notice%20I%20didn't%20need%20to%20specify%20a%20path%20to%20the%20DLL%20since%20it%20was%20on%20my%20system%20path.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%3D%20%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3ELoad%20DLL%3C%2FSPAN%3E(%22mpr.dll%22)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ENext%2C%20you%20need%20to%20declare%20any%20method%20that%20you%20are%20going%20to%20call%20in%20the%20DLL.%20The%20method%20I%20want%20to%20use%20is%20actually%20called%20WNetGetUserA()%2C%20but%20by%20defining%20an%20alias%2C%20I%20can%20simply%20call%20it%20using%20GetUserName().%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20DeclareFunction(%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22WNetGetUserA%22%3C%2FSPAN%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Convention(%20STDCALL%20)%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Alias%20(%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22GetUserName%22%3C%2FSPAN%3E%20)%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E(%20UInt8%2C%20%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22format%22%3C%2FSPAN%3E%2C%20input%20)%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E(%20AnsiString%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22username%22%3C%2FSPAN%3E%2C%20output%20)%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EArg%3C%2FSPAN%3E(%20UInt64%2C%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%20%22length%22%3C%2FSPAN%3E%2C%20update%20)%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Returns(%20UInt32%20)%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ENow%20I%20want%20to%20define%20the%20variables%20that%20I%20am%20going%20to%20pass%20in%20as%20arguments.%20I%20create%20a%20username%20and%20initialize%20it%20to%20blanks.%20Then%20I%20use%20the%20length()%20function%20in%20JMP%20to%20get%20the%20current%20length%20of%20the%20buffer%20I%20just%20created.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Eusername%20%3D%20%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22%3C%2FSPAN%3E%20%3B%3C%2FP%3E%3CP%3Eunlen%20%3D%20%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3Elength%3C%2FSPAN%3E(username)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ENow%20I%20can%20call%20the%20function.%20Notice%20the%20first%20argument%20is%20input%20only%2C%20so%20I%20just%20use%20a%20constant%20instead%20of%20defining%20a%20variable.%20Then%20the%20show()%20command%20shows%20my%20username%20after%20making%20the%20call.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Eresult%20%3D%20dll%20%26lt%3B%26lt%3B%20GetUserName(%3CSPAN%20style%3D%22color%3A%20%23008000%3B%22%3E0%3C%2FSPAN%3E%2C%20username%2C%20unlen)%3B%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3Eshow%3C%2FSPAN%3E(username)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EFinally%2C%20I%20am%20done%20so%20I%20clean%20up.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Edll%20%26lt%3B%26lt%3B%20UnloadDLL()%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EI%20hope%20this%20works%20for%20you.%20If%20you%20come%20up%20with%20a%20better%20way%2C%20please%20let%20us%20know.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EBy%20the%20way%2C%20using%20loadDLL%20only%20works%20on%20Windows.%20It%20isn't%20supported%20on%20the%20Mac.%20For%20that%20reason%20I%20do%20a%20check%20at%20the%20top%20of%20my%20script.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3ENames%20Default%20To%20Here%3C%2FSPAN%3E(%20%3CSPAN%20style%3D%22color%3A%20%23008000%3B%22%3E1%3C%2FSPAN%3E%20)%3B%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EIf%3C%2FSPAN%3E(%20%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EHost%20is%3C%2FSPAN%3E(%20Mac%20)%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EPrint%3C%2FSPAN%3E(%20%3CSPAN%20style%3D%22color%3A%20%23800080%3B%22%3E%22Sorry%2C%20this%20script%20is%20not%20supported%20on%20Mac.%22%3C%2FSPAN%3E%20)%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20style%3D%22color%3A%20%230000ff%3B%22%3EStop%3C%2FSPAN%3E()%3B%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EEnjoy%2C%3C%2FP%3E%3CP%3EJohnP%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3468%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20computer%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3468%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ECan%20someone%20help%20me%20with%20the%20syntax%20for%20calling%20a%20DLL%3F%26nbsp%3B%20I%20want%20to%20get%20the%20user's%20username%20using%20the%20Windows%20API%20GetUserName%20function.%26nbsp%3B%20I%20don't%20want%20to%20look%20up%20the%20username%20environment%20variable%20because%20that%20can%20be%20spoofed.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EAdvapi32.dll%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EBOOL%20WINAPI%20GetUserName(%3C%2FP%3E%3CP%3E%26nbsp%3B%20_Out_%26nbsp%3B%26nbsp%3B%26nbsp%3B%20LPTSTR%20lpBuffer%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%20_Inout_%26nbsp%3B%20LPDWORD%20lpnSize%3C%2FP%3E%3CP%3E)%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3467%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20computer%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3467%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EHi%3A%3CBR%20%2F%3E%3CBR%20%2F%3EAssuming%20Windows%20XP%20and%20JMP%208%20one%20can%20retrive%20Windoz%20variables%20via%20the%20LoadDLL%20command%20-%20(also%20with%20JMP%209%20if%20one%20wants%20to%20retrieve%20all%20of%20the%20ENV%20variables).%20%3CBR%20%2F%3E%3CBR%20%2F%3EExample%20below%20uses%20the%20%22GetEnvironmentStrings%22%20windows%20function%20to%20retrive%20all%20the%20global%20environmental%20variables%20(including%20COMPUTERNAME)%20and%20for%20fun%20loads%20then%20in%20a%20data%20table%20and%20an%20array.%3CBR%20%2F%3E%3CBR%20%2F%3Esee%3A%3CBR%20%2F%3E%3CA%20href%3D%22http%3A%2F%2Fwww.nesug.org%2FProceedings%2Fnesug10%2Fad%2Fad04.pdf%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fwww.nesug.org%2FProceedings%2Fnesug10%2Fad%2Fad04.pdf%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3EBest%20regards%2C%3CBR%20%2F%3E-Matt%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3466%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20computer%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3466%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3Ehi%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3Ei%20am%20using%20jmp%208%20is%20there%20a%20similar%20function%20there%20that%20retrieve%20the%20computer%20nam%3CBR%20%2F%3E%3CBR%20%2F%3Etanks%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3465%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20computer%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3465%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EHi%20Pneil%3A%3CBR%20%2F%3E%3CBR%20%2F%3EOn%20Windose%2C%20from%20the%20start%20menu%2C%20run%2C%20cmd%20opens%20a%20DOS%20window.%20From%20the%20prompt%20type%20%22set%22%20for%20the%20list%20of%20active%20environmental%20variables.%3CBR%20%2F%3E%3CBR%20%2F%3EAlso%20-%20right-click%20on%20the%20My%20COmputer%20icon%20on%20the%20desktop%20-%20sleect%20Advanced%20tab%20environmental%20variables%20button%20near%20the%20bottom.%3CBR%20%2F%3E%3CBR%20%2F%3EJMP%209%20includes%20the%20handy%20function%20to%20retrieve%20any%20one%20of%20these%20from%20the%20environment%3A%3CBR%20%2F%3E%3CBR%20%2F%3Ecname%20%3D%20Get%20Environment%20Variable(%20%22COMPUTERNAME%22%20)%3B%3CBR%20%2F%3E%3CBR%20%2F%3Eand%20one%20can%20branch%20accordingly%20base%20on%20the%20returned%20value%20from%20there.%3CBR%20%2F%3E%3CBR%20%2F%3EBest%20regards%2C%3CBR%20%2F%3E-Matt%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-753036%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20computer%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-753036%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThis%20worked%20for%20me%20to%20get%20the%20current%20user%20name%20on%20Windows%3A%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Euname%20%3D%20Get%20Environment%20Variable(%20%22USERNAME%22%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
pniel
Level I

computer name

Hi jmpers,

I need to build an application in jmp for different users, meaning that different users will have different User Interface.. (it is the same application) I was wondering if is there a way to get user profile? Let say computer name, user name or server name from jmp ? Doing so I can decide which script to open

Tanks

pniel
17 REPLIES 17
pmroz
Super User

Re: computer name

Can someone help me with the syntax for calling a DLL?  I want to get the user's username using the Windows API GetUserName function.  I don't want to look up the username environment variable because that can be spoofed.

Advapi32.dll

BOOL WINAPI GetUserName(

  _Out_    LPTSTR lpBuffer,

  _Inout_  LPDWORD lpnSize

);

Thanks!

JohnPonte
Staff (Retired)

Re: computer name

Here is some JSL that I wrote for getting the username from the system. This worked in JMP 10, running on Windows 7.

dll = Load DLL( "mpr.dll" );

dll << DeclareFunction(

     "WNetGetUserA",

      Convention( STDCALL ),

      Alias ( "GetUserName" ),

      Arg( UInt8, "format", input ),

      Arg( AnsiString, "username", output ),

      Arg( UInt64, "length", update ),

      Returns( UInt32 )

);

username = "                                                  ";

unlen = length(username);

result = dll << GetUserName(0, username, unlen);

show(username);

dll << UnloadDLL();

First, you need to load the system DLL. I didn't have any luck with Advapi32.dll. But I found what I needed with mpr.dll. Notice I didn't need to specify a path to the DLL since it was on my system path.

dll = Load DLL("mpr.dll");

Next, you need to declare any method that you are going to call in the DLL. The method I want to use is actually called WNetGetUserA(), but by defining an alias, I can simply call it using GetUserName().

dll << DeclareFunction(

      "WNetGetUserA",

      Convention( STDCALL ),

      Alias ( "GetUserName" ),

      Arg( UInt8, "format", input ),

      Arg( AnsiString, "username", output ),

      Arg( UInt64, "length", update ),

      Returns( UInt32 )

);

Now I want to define the variables that I am going to pass in as arguments. I create a username and initialize it to blanks. Then I use the length() function in JMP to get the current length of the buffer I just created.

username = "                                                  " ;

unlen = length(username);

Now I can call the function. Notice the first argument is input only, so I just use a constant instead of defining a variable. Then the show() command shows my username after making the call.

result = dll << GetUserName(0, username, unlen);

show(username);

Finally, I am done so I clean up.

dll << UnloadDLL();

I hope this works for you. If you come up with a better way, please let us know.

By the way, using loadDLL only works on Windows. It isn't supported on the Mac. For that reason I do a check at the top of my script.

Names Default To Here( 1 );

If( Host is( Mac ),

     Print( "Sorry, this script is not supported on Mac." );

     Stop();

);

Enjoy,

JohnP

pmroz
Super User

Re: computer name

JohnP,

Thanks so much!  That's exactly what I'm looking for.  Can't mark this as the correct answer because I didn't start this thread.

JohnPonte
Staff (Retired)

Re: computer name

The original post also asked about the computer name. To get the computer name, use Kernel32.dll and the method name, GetComputerNameA(). So it will look like this:

dll = Load DLL( "Kernel32.dll" );

dll << DeclareFunction(

     "GetComputerNameA",

      Convention( STDCALL ),

      Alias ( "GetComputerName" ),

      Arg( AnsiString, "computername", output ),

      Arg( UInt64, "length", update ),

      Returns( UInt32 )

);

name = "                                                  ";

unlen = length(name);

result = dll << GetComputerName(name, unlen);

show(name);

dll << UnloadDLL();

JohnP

mattflynn
Level III

Re: computer name

JMP 10 supports this query directly

Get Enviromental Variable("Computername")

Best,

-Matt

pmroz
Super User

Re: computer name

I need something that can't be hacked by something as simple as setting the environment variable.  Thanks JohnP for both solutions!

jmpbeginner
Level III

Re: computer name

thanks, syntax in JMP12 is actually:

Get Environment Variable("Computername");

Byron_JMP
Staff

Re: computer name

For Mac OS

 

Try this:

If( Host is( "Mac" ),username=Get Environment Variable( "USER" );
	stamp="Test "||username||", "||char(today());
);
JMP Systems Engineer, Health and Life Sciences (Pharma)