You might try this to see what values you get.
Code:
break on
? "Test 1: %clientname%"
? "Test 2: "
$clientname=CreateObject("WScript.Shell").ExpandEnvironmentStrings("%CLIENTNAME%")
$clientname
? "Test 3: "
$clientname=EXPANDENVIRONMENTVARS("%clientname%")
$clientname
? "Test 4: "
$output=wshpipe('%comspec% /c set clientname',1)
for each $line in $output
split($line,"=")[1]
next
Function WshPipe($ShellCMD, OPTIONAL $NoEcho)
Dim $oExec, $Output
$oExec = CreateObject("WScript.Shell").Exec($ShellCMD)
If Not VarType($oExec)=9 $WshPipe="WScript.Shell Exec Unsupported" Exit 10 EndIf
$Output = $oExec.StdOut.ReadAll + $oExec.StdErr.ReadAll
If Not $NoEcho $Output Endif
$WshPipe=Split(Join(Split($Output,CHR(13)),''),CHR(10))
Exit($oExec.ExitCode)
EndFunction