Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for whoami.cmd

(view source code of whoami.cmd as plain text)

  1. /* Get wksta information */
  2.  
  3. call RxFuncAdd 'LoadLsRxutFuncs', 'LSRXUT', 'LoadLsRxutFuncs'
  4. call LoadLsRxutFuncs
  5.  
  6. NETWKSTA = 350
  7. parse upper arg SrvName dummy
  8. if dummy <> '' then call Syntax
  9. SrvName = strip( SrvName )
  10. if pos( '?', SrvName ) > 0 then call Syntax
  11. if pos( '*', SrvName ) > 0 then SrvName = ''
  12. if left( SrvName, 2 ) <> '\\' & SrvName <> '' then SrvName = '\\'||SrvName
  13.  
  14. myRc = NetGetInfo(NETWKSTA, 'wkstaInfo', SrvName)
  15.  
  16. if myRc <> '0' then do
  17. 	say 'Got error from NetGetInfo(NETWKSTA) ' myRc
  18. 	exit 9
  19. end
  20.  
  21. say
  22. say 'Computer Name        : ' wkstaInfo.computername
  23. say 'User Id logged on    : ' wkstaInfo.username
  24. say 'LAN Group            : ' wkstaInfo.langroup
  25. say 'Major version number : ' wkstaInfo.ver_major
  26. say 'Minor version number : ' wkstaInfo.ver_minor
  27. say 'Logon domain         : ' wkstaInfo.logon_domain
  28. say 'Other domains        : ' wkstaInfo.oth_domains
  29.  
  30. exit 0
  31.  
  32.  
  33. Syntax: procedure
  34. 	say
  35. 	say "WhoAmI"
  36. 	say
  37. 	say "Usage:  WHOAMI  [ { \\server | * } ]"
  38. 	exit 1
  39. return
  40.  

page last uploaded: 2017-08-21, 14:26