Stiddy:
That's some great stuff you posted. I gave you a star, even though I tried your script and it didn't quite work out perfectly. My organization running WindowsXP Pro, and we've deployed 80 machines already. We have a need to put a login security notice, located in
HKLM\Software\Microsoft\Windows NT\CurrentVersion\WinLogon
under two keys:
LegalNoticeCaption
LegalNoticeText
I've got two batch files, readlist.bat and regupd.bat .
==========================================================
readlist.bat:
for /f "tokens=1-2" %%a in (c:\test\workstat.txt) do call c:\test\regupd.bat %%a
regupd.bat:
REM This batch file will loop until the complete computer list
REM is read. Each computer name from workstat.txt will be read
REM into this batch program as a variable %1 .
REM This part will copy the executable service program to the remote
REM computer, to whatever path specified below
xcopy rcmdsvc.exe \\%1\c$ /y
REM This part will create the rcmdsvc.exe (Remote Command Service)
REM service on the remote computer.
sc \\%1 create "remote command" binpath= c:\rcmdsvc.exe
REM This part will start the service that we just created on the
REM remote computer.
sc \\%1 start "remote command"
REM Now we can execute any command we want on the remote computer.
REM Keep in mind, that you will need to specify the full path
REM of the command. If the path or filename is longer than
REM 8 characters, you will need to enclose the path with
REM double-quotation marks, "" . Also, you cannot import a registry
REM entry into \\HKEY_CURRENT_USER, as that key is on a per-user
REM basis, and must be imported locally on the workstation under
REM the user's credentials.
rcmd \\%1 c:\windows\regedit.exe /s /i \\<server name>\netlogon\disclaimer.reg
REM The remote command is now finished. Now we will stop and
REM then delete the remote service we just created.
sc \\%1 stop "remote command"
sc \\%1 delete "remote command"
REM Now finally we will remote the remote command service executable
REM file from the remote machine
del \\%1\c$\rcmdsvc.exe /q
REM This last entry will keep track of which registry changes
REM were successful. If the computer name is not in the log
REM file, then the reg change was not successful.
Echo >> C:\test\complete.log %1 Registry change complete
REM All done!
==========================================================
Now the problem is that the batch file executes correctly on the client side, but on the remote side, the registry does not import properly. I can walk over to the remote computer, log in with administrator rights, and run the exact same commmand, and it works fine. Is there some quirk that I'm not aware of, by using the rcmd command with regedit? I realize this is a stale post, but it hits the nail on the head for what my organization is trying to do, AND the batch file provides a great amount of flexibility for what we can also do down the road. Thanks!