Archive: Will %COMPUTERNAME% work on NT/9x?


Will %COMPUTERNAME% work on NT/9x?
I am using ReadEnvStr to read COMPUTERNAME and USERNAME environment variables and it works just fine on XP/Win2k, but does anyone know will it work on NT/9x? :)

I know there is other ways read the computername or username, but if ReadEnvStr method works on NT/9x I would rather use it than any other method. :rolleyes:


UserInfo::GetName can get you the user name using Windows API. To get the computer name, the System plug-in is required.

System::Call "kernel32::GetComputerName(t .r0, *i ${NSIS_MAX_STRLEN})"
No need for environment variables or the registry ;)

To elaborate a bit more, I don't trust the environment variables. I have never seen official documentation concerning which versions of Windows export which variables. And on top of that, the user can easily change them and leave you with false values. I put my trust in the API.


Thank you. :) That will do just fine. And with quick search to msdn.

System::Call "Advapi32::GetUserName(t .r0, *i ${NSIS_MAX_STRLEN})"