[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • Last Modified:

How can I bundle/package up and deploy a .HTM, .NTK, and .DLL file to 400 Windows 7 machines?

How can I bundle/package up and deploy a .HTM, .NTK, and .DLL file to 400 Windows 7 machines?

Problem:  We have 400 KIOSK with Windows 7 OS on it that recently had some technical issues. The Netkey support technician was able to fix the issues, and we tested it with one Kiosk. It works! The support tech updated a .HTM, .NTK, and .DLL file on the machine.

Deployment Method: The question is how do we deploy the fix to 400 machines? We need to find a method were we can deploy the newly updated  .HTM, .NTK, and .DLL file to it’s current directory. In turn, we need a way to where the current file (which will be replace by the updated file) will get renamed to .old. Can this be achieved by PSEXEC, script, .BAT,  GPO? If we can accomplish this, please detail step-by-step example on how this can be done using the example in the screenshot, with the directory path as indicated. Thank you.

Here is what we want accomplished (see screenshot).
File Replacement
0
joukiejouk
Asked:
joukiejouk
  • 2
  • 2
1 Solution
 
oBdACommented:
You can do that with a GPO and a startup script applied to the machines in question.
Note: if UAC is active, you might get a prompt to change the permissions when accessing the netlogon folder; instead of changing the permissions, use either a command/powershell prompt started elevated to copy the files, or use a third-party Explorer you can start elevated (you can't run Windows Explorer elevated). Personally, I like Explorer++ (https://explorerplusplus.com/) for that, because it doesn't require installation.
* In the netlogon share on your DC (usually C:\Windows\SYSVOL\domain\scripts, or connect from a client to \\<SomeDC>\netlogon), create a folder "Big5Kiosk_v4".
* Put the files you want to copy into this folder.
* Save the script below as Big5Kiosk.cmd directly in the netlogon folder (not in the Big5Kiosk_v4 folder);  in line 3, change the domain name to your domain's FQDN, and in line 4, change/add the file names to copy.
* Move a test machine into a test OU, create a new GPO "Big5Kiosk" or whatever, and link it to that OU.
* Edit the GPO, and go to "Computer Configuration\Policies\Windows Settings\Scripts (Startup/Shutdown)
* Right-click "Startup" and choose "Properties".
* Click "Add", and enter "\\<your.domain.fqdn>\netlogon\Big5Kiosk.cmd as Script Name (do NOT use the "Browse" dialog).
* Reboot the test client.
* If everything went OK, you should find the new files in the target folder; you can then either add some more test clients to the test OU, or link the GPO to the OU(s) with the rest of the clients and reboot those as well.
If the new files aren't there, check the log file "C:\Windows\Temp\Big5Kiosk.log".
If the log file isn't there, check the System event log for errors applying the GPO.
You can use the same script to revert to the old files, or apply another update; just replace the files in the netlogon\Big5Kiosk folder and reboot the clients again.
@echo off
setlocal enabledelayedexpansion
set DomainFqdn=your.domain.fqdn
set CopyFiles="nkscripts.htm" "NKVolCrtl.dll"
set SourceFolder=\\%DomainFqdn%\netlogon
set TargetFolder=C:\Big5Kiosk_v4\bin

set LogFile=%Systemroot%\Temp\%~n0.log
>"%LogFile%" echo %~nx0 started at %Date% %Time%
if not exist "%TargetFolder%" (
	>>"%LogFile%" echo ERROR: Target folder '%TargetFolder%' not found!
	goto Done
)
for %%a in (%CopyFiles%) do call :Process "%%~a"
>>"%LogFile%" echo %~nx0 finished at %Date% %Time%
goto :eof

:Process
>>"%LogFile%" echo Processing '%~1' ...
if not exist "%SourceFolder%\%~1" (
	>>"%LogFile%" echo ERROR: Source file '%SourceFolder%\%~1' not found!
	goto :eof
)
for %%a in ("%SourceFolder%\%~1") do set SourceDate=%%~ta
if exist "%TargetFolder%\%~1" (
	for %%a in ("%TargetFolder%\%~1") do set TargetDate=%%~ta
	if "!SourceDate!"=="!TargetDate!" (
		>>"%LogFile%" echo ... skipped, found in the same version.
		goto :eof
	) else (
		set TimeStamp=!TargetDate: =_!
		set TimeStamp=!TimeStamp:/=!
		set TimeStamp=!TimeStamp::=!
		set TimeStamp=!TimeStamp:.=!
		set BackupFile=%~1.!TimeStamp!.old
		if exist "%TargetFolder%\!BackupFile!" (
			>>"%LogFile%" echo ... changed version, backup file already exists: reverting to previous version ...
		) else (
			>>"%LogFile%" echo ... changed version, renaming existing file to '!BackupFile!' ...
			ren "%TargetFolder%\%~1" "!BackupFile!" >>"%LogFile%" 2>&1
			if errorlevel 1 (
				>>"%LogFile%" echo ERROR: failed to rename!
				goto :eof
			)
		)
	)
)
>>"%LogFile%" echo ... copying '%SourceFolder%\%~1' to '%TargetFolder%' ...
copy "%SourceFolder%\%~1" "%TargetFolder%" >>"%LogFile%" 2>&1
if errorlevel 1 (
	>>"%LogFile%" echo ERROR: failed to copy!
	goto :eof
)
>>"%LogFile%" echo ... OK.
goto :eof

Open in new window

0
 
joukiejoukAuthor Commented:
Hello,

I followed your steps but to no avail. Please see my screenshot and if something does not look right, let me know.

1. I made some edits to your script and applied it to my environment.
script correction
2. My GPO Config on a DC.
gpo config
gpo config 2
3. From client machine
client machine
client error log
0
 
oBdACommented:
You're nearly there, the missing part is my bad, sorry.
In Line 5, SourceFolder is missing the subfolder with the files (and you can leave %DomainFqdn% as it is), so it needs to be
set SourceFolder=\\%DomainFqdn%\netlogon\Big5Kiosk_v4

Open in new window

0
 
joukiejoukAuthor Commented:
Can this be done through PSEXEC? If so, can you detail the steps?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now