Search code examples
windowssolarwindslem

Windows login script to add line in configuration file


I am new to this website, and fairly inexperienced with scripting, so be easy on me.

For this particular issue, my environment consists of roughly 1,000 Windows 7 PCs. Every PC has a Solarwinds Log and Event Manager agent running in the background that writes to a LEM server for each PC. Each PC has a configuration file titled spop.conf located in C:\Windows\SysWOW64\ContegoSPOP (I am assuming all PCs are 64 bit). I need to add the line "UseLocalEnvironmentVariableForLocalHost=true" to that file on all PCs in the environment. To do this, I also need to stop the service "Contego_Spop" and restart it after editing. Would it be best to create a new spop.conf file with this line in it and push that out via script?

Does anyone have some words of wisdom for a newbie? Thank you for any help you can give.


Solution

  • I assume you're a domain admin.

    Write a .bat file fix.bat that accepts computer name, edits the config file and restarts the service.

    sc \\%1 stop Contego_Spop
    echo UseLocalEnvironmentVariableForLocalHost=true >>\\%1\c$\Windows\SysWOW64\ContegoSPOP\spop.conf
    sc \\%1 start Contego_Spop
    

    run this bat file for each computer name

    C:\> call fix.bat host1
    C:\> call fix.bat host2
    C:\> call fix.bat host3
    ...