Jump to content

Batch file with variables not working?


Recommended Posts

Hello,

I have a small problem with the following script:

SET COMPNUM = 001

SET COMPNAME = TestClient%COMPNUM%

SET COMPNAME

REG add "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" /v ComputerName /t REG_SZ /d %COMPNAME% /f

Whenever I run the batch, the REG command shows up as

REG add "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" /v ComputerName /t REG_SZ /d /f

however the SET COMPNAME shows me "TestClient001", what am I doing wrong with that REG command?

Quick help would be very much appreciated! ;)

mf_2

Link to comment
Share on other sites


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 Off
Setlocal
(Set COMPNUM=001)
(Set COMPNAME=TestClient%COMPNUM%)
Reg Add HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName /v ComputerName /d "%COMPNAME%" /f>Nul

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...