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
218 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 83

Accepted Solution

by:
oBdA earned 500 total points
ID: 40585682
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
ID: 40590413
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 83

Expert Comment

by:oBdA
ID: 40590458
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
ID: 40592583
Can this be done through PSEXEC? If so, can you detail the steps?
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Resolve DNS query failed errors for Exchange
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

778 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