String Manipulation with environment variables (%computername%)
Does anyone know how to manipulate strings such as %computername%? I only want the left three digits from the computername but when I try left(%computername%,3) it takes it literally in theglobal policy preferences variables.
July 2nd, 2008 5:22am

Hello, As far as I know, there is no such a function that can manipulate strings of the existing variables. I will forward the function requirement to product group. Thanks for your reporting. As a workaround, you can set up a computer startup or user logon script to create custom variables from a part of the existing variables. After the custom environmental variable is generated, you can use it in group policy preference configuration. ---------------------------------------- Const HKEY_LOCAL_MACHINE = &H80000002 strComputer = "." Set Shell = CreateObject("WScript.Shell") ComputerName = Shell.ExpandEnvironmentStrings("%ComputerName%") MyVariable = Mid(ComputerName, 1, 3) Set objShell = WScript.CreateObject("WScript.Shell") Set colsysEnvVars = objShell.Environment("SYSTEM") colsysEnvVars("custom_variable") = MyVariable ---------------------------------------- For your reference: Environment Variables http://www.microsoft.com/technet/scriptcenter/guide/sas_wsh_kmmj.mspx Functions (VBScript) http://msdn.microsoft.com/en-us/library/3ca8tfek(VS.85).aspxI find that you have another duplicated post in the Group Policy queue.Would you mind ifwe discuess this question in that post?
Free Windows Admin Tool Kit Click here and download it now
July 4th, 2008 12:08pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics