mf_2 Posted July 5, 2007 Posted July 5, 2007 Hello,I have a small problem with the following script:SET COMPNUM = 001SET COMPNAME = TestClient%COMPNUM%SET COMPNAMEREG add "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" /v ComputerName /t REG_SZ /d %COMPNAME% /fWhenever I run the batch, the REG command shows up asREG add "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" /v ComputerName /t REG_SZ /d /fhowever the SET COMPNAME shows me "TestClient001", what am I doing wrong with that REG command?Quick help would be very much appreciated! mf_2
patrickb Posted July 5, 2007 Posted July 5, 2007 reg_sz does not work with variables, you need reg_expand_sz
mf_2 Posted July 5, 2007 Author Posted July 5, 2007 The problem remains. Also, the REG_SZ has worked before. I really don't know why it's not working now. Does anybody have a clue?
mf_2 Posted July 5, 2007 Author Posted July 5, 2007 Problem solved:The whitespaces around the equal sign have to go."SET var=value" works like a charm, unlike "SET var = value"
Yzöwl Posted July 5, 2007 Posted July 5, 2007 Well I'm glad you spotted it, you'd have noticed it if you'd used the examples you'd already been given yesterday!@Echo OffSetlocal(Set COMPNUM=001)(Set COMPNAME=TestClient%COMPNUM%)Reg Add HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName /v ComputerName /d "%COMPNAME%" /f>Nul
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now