Jump to content

Need to rename file based on %string% comparison


Recommended Posts

This is somewhat related to the sysprep script I needed to query MAC Address and look it up in database to find appropriate ComputerName & ProductKey.

In the script, ComputerName is represented by the string %strComputername% and Product key is represented by %strProduct%. I have 25 machines and although they need to be pretty much identical,there are a few that will have some external hardware and applications. So I have a few different post install files (postinst1.bat, postinst2.bat.....postinst12.bat,etc.) and what I need to do is Compare the machine name OR product key to something and if it matches, rename the file from postintx.bat to postinstall.bat.

I tried this, and the script/command window just exits

IF %strComputername%="Gateway-01" REN postinst1.bat postinstall.bat else echo.

IF %strComputername%="Gateway-02" REN postinst2.bat postinstall.bat else echo.

IF %strComputername%="Gateway-03" REN postinst3.bat postinstall.bat else echo.

What am I doing wrong??

Link to comment
Share on other sites


Use == instead of =, and you might need quotes around %strComputername%

IF "%strComputername%"=="Gateway-03" REN postinst3.bat postinstall.bat else echo.
Edited by Dahi
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...