Home upgrade word template file with batch
Reply: 0

upgrade word template file with batch

skatun
1#
skatun Published in 2017-12-07 12:40:01Z

I have a word template file stored on network disk which I need to copy over to the user if it is different from the one on the user computer:

 ver = Val(Normal.Post.helpRequest2("xxxxx"))
    If ver > Val(Normal.Settings.wordMakroVersjon) Then
        If MsgBox("Do you want to upgrade to " & CStr(ver) & "?", vbYesNo) = vbYes Then
            Shell "cmd.exe /k " & Settings.CMRDISK & "Dokumentstyring\updateWord.bat"
        End If
    End If

This then execute the batch script:

call Z:\Dokumentstyring\startWord.bat

taskkill /F /IM WinWord.exe /T


exit 0

Which calls another batchscript with a delay so that the first batch script can close down word so that the file can be copied with the second batch script:

ping -n 3 127.0.0.1 > nul

del %APPDATA%\Microsoft\Templates\Normal*.dotm

echo f | xcopy /f  /y /z  "Z:\Dokumentstyring\ReleasedVersion\Normal.dotm" "%APPDATA%\Microsoft\Templates\Normal.dotm" 


echo f | xcopy /f  /y /z  "Z:\Dokumentstyring\ReleasedVersion\ReleaseNote*" "%APPDATA%\Microsoft\Templates\Release.txt" 
echo Start word again
start /B "Word" "C:\Program Files (x86)\Microsoft Office\root\Office16\Winword.exe"

echo terminating the batch script

exit 0

The problem is the batch scripts, word might be closed but the process might be hanging in the taskmanager, because the user has a preview of a file in the explorer. I thought this should solve it:

taskkill /F /IM WinWord.exe /T

But it does not, how can I force copy and overwrite the file and make sure that I kill all apllication that uses the file?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.331061 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO