A Power Shell example of how to greet your users when then launch AutoCAD. Yes, its a silly frill, but its kinda cool and the user will be surprised to see it.
;;;-----------------------------------------
(defun CA:GetFirstName (/ CA_name CA_cmd CA_sh CA_ex)
(or (getenv "CA_FIRSTNAME")
(progn
(setq CA_cmd (strcat "powershell -NoProfile -Command " "\"(New-Object System.DirectoryServices.DirectorySearcher('(samAccountName=' + $env:USERNAME + ')')).FindOne().Properties.givenname\""))
(setq CA_sh (vlax-create-object "WScript.Shell"))
(setq CA_ex (vlax-invoke ET_sh 'Exec ET_cmd))
(setq CA_name (vl-string-trim " \r\n\t" (vlax-invoke (vlax-get ET_ex 'StdOut) 'ReadAll)))
(vlax-release-object ET_sh)
(setenv "CA_FIRSTNAME" ET_name);; cache for future sessions
;name
);progn
);or
(princ)
);defun
(CA:GetFirstName)
;;;-----------------------------------------
;;;-----------------------------------------
(defun CA_greeting (/ CA_x CA_hr CA_tod)
;; Get current hour (00-23)
(setq CA_hr (atoi (menucmd "M=$(edtime,$(getvar,date),HH)")))
;; Determine time-of-day greeting
(setq CA_tod
(cond
((< CA_hr 12) "Good Morning")
((< CA_hr 18) "Good Afternoon")
(T "Good Evening")
)
)
;; Build and display message
(setq CA_x
(strcat "\n" CA_tod " " (getenv "ET_FIRSTNAME") ". Have a great day!\n")
)
(princ CA_x)
(princ)
)
(CA_greeting)
;;;-----------------------------------------