Skip to content
⌘ NSIS Forum Archive

Computer name to string

4 posts

parasoul#

Computer name to string

Is there a way, using no windows enviornmental variables (cmd.exe) using NSIS alone to put the computer name into a string variable to further change a file name to the computer name

thank you
bwinterscheidt#
How about this?

NSIS Code Examples: Your Computer Name

nsis.sourceforge.net/Your_Computer_Name
Afrow UK#
If you don't need to Win 9x, you can also call the kernel32::GetComputerName() API with the System plug-in.
Examples of using GetUserName() on this forum are almost identical.

Stu
Swapan Das#
I'm not sure whether you were looking for a solution like the following:

Var ComputerName
Call GetComputerName

Function GetComputerName
ReadRegStr $0 HKLM "System\CurrentControlSet\Control\ComputerName\ActiveComputerName" "ComputerName"
StrCmp $0 "" win9x
StrCpy $1 $0 4 3
StrCpy $ComputerName $0
Goto done
win9x:
ReadRegStr $0 HKLM "System\CurrentControlSet\Control\ComputerName\ComputerName" "ComputerName"
StrCpy $1 $0 4 3
StrCpy $ComputerName $0
done:
FunctionEnd


Regards,
Swapan