mrtn
Posts: 6
Joined: Tue Jun 02, 2020 1:33 pm

Intune LOB app for Normal.dotm

I have followed this tutorial to create an Intune LOB app that installs the Normal.dotm to the correct folder in Windows. https://www.altitude365.com/2017/08/18/ ... ft-office/

The issue is, that if the likely situation occurs, that the first run of Word in the actual machine takes place after the installation of the LOB app, then the customized file is overwritten by the default Word template.

Also, I have found no way to actually install this for every user that logs in to the computer with their own Azure Ad account: the LOB app is installed only once, and Intune only checks that the app is installed, not that the Normal.dotm being used is the correct one.

Is there a workaround for this in the Advanced installer app?
Catalin
Posts: 6582
Joined: Wed Jun 13, 2018 7:49 am

Re: Intune LOB app for Normal.dotm

Hello and welcome to Advanced Installer forums,
Also, I have found no way to actually install this for every user that logs in to the computer with their own Azure Ad account: the LOB app is installed only once, and Intune only checks that the app is installed, not that the Normal.dotm being used is the correct one.
Here, you could try to follow the how-to created by my colleague Dan. Here is the link to the forum thread where he has explained how to deliver a file to all user profiles:

Deliver a file to all user profiles programmatically
The issue is, that if the likely situation occurs, that the first run of Word in the actual machine takes place after the installation of the LOB app, then the customized file is overwritten by the default Word template.
In what regards this, unfortunately, I am afraid there is not much we can do about it.

If I understand correctly, you are trying to install a blank document which can be modified, for instance, by a user, but which can not be modified (overwritten) by the first run of Word.

A solution to this would be to set the "Read-Only" attribute for the file. To do so, you can open Advanced Installer --> "Files and Folders" page --> double click on your file --> "Properties" tab --> "Attributes" section --" check the "Read-Only" attribute.

However, this way, a user will also not be able to overwrite the file.

Hope this helps somehow.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mrtn
Posts: 6
Joined: Tue Jun 02, 2020 1:33 pm

Re: Intune LOB app for Normal.dotm

EDIT: At first, I didn't realize it was possiblie to post a reply to Dan's post- Now, I posted this question as a reply to the original post. Sorry for the double posting ...
Catalin wrote: Wed Jun 03, 2020 10:30 am Here, you could try to follow the how-to created by my colleague Dan. Here is the link to the forum thread where he has explained how to deliver a file to all user profiles:

Deliver a file to all user profiles programmatically
Thanks! That's great :) But sadly I must be doing something wrong. The folder is copied perfectly, but the files are not copied.

My aim is to copy custom Office templates to the folder "My Documents\Anpassade Office-mallar", so I have modified the script. Maybe there are errors there?

FOR /f "tokens=*" %%G in ('dir /b /a:d-s-l "%SystemDrive%\Users"') DO (
IF /I NOT "%%G"=="Public" (
IF NOT EXIST "%SystemDrive%\Users\%%G\Documents\Anpassade Office-mallar\test.txt" md "%SystemDrive%\Users\%%G\Documents\Anpassade Office-mallar"
IF NOT EXIST "%SystemDrive%\Users\%%G\Documents\Anpassade Office-mallar\test2.txt" md "%SystemDrive%\Users\%%G\Documents\Anpassade Office-mallar"
xcopy.exe %1 "%SystemDrive%\Users\%%G\Documents\Anpassade Office-mallar" /C /I /Q /R /K /Y
)
)
Catalin
Posts: 6582
Joined: Wed Jun 13, 2018 7:49 am

Re: Intune LOB app for Normal.dotm

Hello,

First of all, please accept my apologies for the delayed reply.

At a first glance, the content of the custom action looks fine.

In order for me to further have a look on this, could you please take a screenshot of how you have configured the Custom Action in Advanced Installer and post it here, e.g.:

LFExample.png
LFExample.png (128.16 KiB) Viewed 7566 times


Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mrtn
Posts: 6
Joined: Tue Jun 02, 2020 1:33 pm

Re: Intune LOB app for Normal.dotm

Hi,
and thanks. No worries about the delay.

The attachment is what my original Custom Action looked like, where the folder was created but the files were not distributed.

After taking this screenshot, I tried to separate the two files with an "," and created an updated version of the app. Now the app did distribute the first file in the list, but not the second. So I suppose it's me not using the correct punctuation?
Attachments
action.png
action.png (41.98 KiB) Viewed 7562 times
Catalin
Posts: 6582
Joined: Wed Jun 13, 2018 7:49 am

Re: Intune LOB app for Normal.dotm

Hello,

Thank you for the provided screenshot.

I believe I may have found the culprit here.

As you can see, the script was created to only deliver one file to a specific folder. This can be seen in the following lines:

Code: Select all

IF NOT EXIST "%SystemDrive%\Users\%%G\AppData\Roaming\MyCompany\demoFile.config" md "%SystemDrive%\Users\%%G\AppData\Roaming\MyCompany"
    xcopy.exe %1 "%SystemDrive%\Users\%%G\AppData\Roaming\MyCompany" /C /I /Q /R /K /Y
As you can see, only one file is created. Additionally, only one file is expected as input. This can be seen in the following line:

Code: Select all

xcopy.exe %1
As you may know, the %1 represents a parameter that is passed to our batch script. For instance, if we have the following .BAT file:

Code: Select all

ECHO Hello %1 %2
(let's say the name is "hello.bat")

If you open a command prompt and call the .BAT file like this:

Code: Select all

hello.bat Catalin Mihai
It will display the following:

Code: Select all

Hello Catalin Mihai
HelloBat.png
HelloBat.png (21.58 KiB) Viewed 7559 times

The "Catalin" value was taken as the first argument and the "Mihai" value was taken as a second argument.


In our case, it is the same. You are creating two files but the "xcopy" command expects only one parameter, while you are giving it two parameters:

[&test2.txt] and [&test.txt]

With that being said, could you please modify the content of your .BAT file to await two parameters as input? To do so, please modify the following:

Code: Select all

xcopy.exe %1 "%SystemDrive%\Users\%%G\AppData\Roaming\MyCompany" /C /I /Q /R /K /Y
to:

Code: Select all

xcopy.exe %1 %2 "%SystemDrive%\Users\%%G\AppData\Roaming\MyCompany" /C /I /Q /R /K /Y
In addiiton to this, as it can be seen in my example, you do not need to have a separator for your parameters, therefore I believe you can remove the ",".

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mrtn
Posts: 6
Joined: Tue Jun 02, 2020 1:33 pm

Re: Intune LOB app for Normal.dotm

Thanks for the effort you put into your reply!
Now I've changed the code to

Code: Select all

FOR /f "tokens=*" %%G in ('dir /b /a:d-s-l "%SystemDrive%\Users"') DO (
  IF /I NOT "%%G"=="Public" (
    IF NOT EXIST "%SystemDrive%\Users\%%G\Documents\Anpassade Office-mallar2\test.txt" md "%SystemDrive%\Users\%%G\Documents\Anpassade Office-mallar2"
    IF NOT EXIST "%SystemDrive%\Users\%%G\Documents\Anpassade Office-mallar2\test2.txt" md "%SystemDrive%\Users\%%G\Documents\Anpassade Office-mallar2"
    xcopy.exe %1 %2 "%SystemDrive%\Users\%%G\Documents\Anpassade Office-mallar2" /C /I /Q /R /K /Y
  )
)
but the result is that the folder "Anpassade Office-mallar2" is created, but no files are copied?
Attachments
2.png
2.png (15.64 KiB) Viewed 7420 times
1.png
1.png (21.79 KiB) Viewed 7420 times
Catalin
Posts: 6582
Joined: Wed Jun 13, 2018 7:49 am

Re: Intune LOB app for Normal.dotm

Hello,

Thank you for your followup on this and for the provided details.

Unfortunately, it seems that I somehow missed the fact that the "xcopy" tool can not accept more than one parameter. Its' syntax is as it follows:

Code: Select all

xcopy.exe [source] [destination] OPTIONS
Based on this, I am afraid that it is not possible to pass two parameters to it.

To overcome this, we might need two script files, checking for the existence of each file and then copying it to the appropriate directory.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mrtn
Posts: 6
Joined: Tue Jun 02, 2020 1:33 pm

Re: Intune LOB app for Normal.dotm

Ah, I see. Then I understand why it didn't work.
I am continuing to work on this, and now I try to simplify the code as much as possible. Maybe this is beyond the support you provide in this forum, but you've been so helpful, so I dare to ask anyway :)

The app I'm creating is to be run manually by clicking the installation file.
The app is supposed to place one file into an existing folder, and overwrite an existing file in that folder. Thus no need to check if the folder exists, and also the "if not exist" part is unnessecary.
I have tried to play around with the code, but it doesn't really do what I want it to.

The original code is
FOR /f "tokens=*" %%G in ('dir /b /a:d-s-l "%SystemDrive%\Users"') DO (
IF /I NOT "%%G"=="Public" (
IF NOT EXIST "%SystemDrive%\Users\%%G\Documents\test.txt" md "%SystemDrive%\Users\%%G\Documents"
xcopy.exe %1 "%SystemDrive%\Users\%%G\Documents" /C /I /Q /R /K /Y
)
)


EDIT: I made it work, although I do not know if the code is correct now. I simply deleted the "NOT" in "IF NOT EXIST". And now it works.
Catalin
Posts: 6582
Joined: Wed Jun 13, 2018 7:49 am

Re: Intune LOB app for Normal.dotm

Hello,

I am really glad I was able to assist and that everything works as expected on your end now. :)

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”