Solved

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

Posted on 2015-02-02
4
210 Views
Last Modified: 2015-02-05
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
Comment
Question by:joukiejouk
  • 2
  • 2
4 Comments
 
LVL 82

Accepted Solution

by:
oBdA earned 500 total points
Comment Utility
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
 

Author Comment

by:joukiejouk
Comment Utility
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
 
LVL 82

Expert Comment

by:oBdA
Comment Utility
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
 

Author Comment

by:joukiejouk
Comment Utility
Can this be done through PSEXEC? If so, can you detail the steps?
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now