GPO applying but logon script not working

Ajoy Rajan
Ajoy Rajan used Ask the Experts™
on
Hi,

We are trying to push a login script using the GPO. The script is to copy the default folder of Google from the roaming profile to the local AppData. It is an Xcopy command. I have converted it into a batch file and copied the batch file to the netlogon and sysvol folder. The GPO is applied but does not run the batch file.

The batch file works by itself and also when we copy the batch file to the startup folder in roaming profile it works. All the other policies are working except this.

We use windows 10 and Server 2012 r2

Please provide any advise.

Regards,

Ajoy
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
NVITEnd-user support

Commented:
Where on the gpo tree is the script running?
Ajoy RajanManaged Service Consultant

Author

Commented:
The ICT Operations team OU. It is linked to the right OU.
NVITEnd-user support

Commented:
But when you edit the gpo/gpp itself. Is it in the Computer or User branch? Since you want to run it during login, i presume it should be in the User branch.

But where, specifically?
Expert Spotlight: Joe Anderson (DatabaseMX)

We’ve posted a new Expert Spotlight!  Joe Anderson (DatabaseMX) has been on Experts Exchange since 2006. Learn more about this database architect, guitar aficionado, and Microsoft MVP.

Ajoy RajanManaged Service Consultant

Author

Commented:
It is in the user branch. Currently for ICT users.
NVITEnd-user support

Commented:
Is your script added to: User Configuration > Windows Settings > Scripts > Logon
Ajoy RajanManaged Service Consultant

Author

Commented:
yes it is.
NVITEnd-user support

Commented:
> ...The GPO is applied but does not run the batch file.

How are you certain the script even running at all? To be certain, troubleshoot each line of the script to see where it may be failing. Above each command line, place ECHO code to redirect to an output file. e.g. this directs output to file %temp%\output.txt:

set fnOut=%temp%\output.txt
>> "%fnOut%" echo command 1
command 1
>> "%fnOut%" echo command 2
command 2

Open in new window


After the user logs on, review the output file.
Ajoy RajanManaged Service Consultant

Author

Commented:
This is the script:

@echo off
echo Do not close this window till copy of files finish:  Thank you ICT Team
xcopy "\\xxx.local\users\%username%\AppData\Google\chrome\Default\*.*" "%localappdata%\Google\Chrome\User Data\Default\" /q /s /e /i /y /c
echo %username% %date% %time% >> \\xxx.local\users\reports\Chrome.txt
exit

I am not sure that the script runs or not. It is applying the GPO but the script do not seem to run. where as when I run the script by copying to the startup folder of the user's roaming profile, it runs as soon as the user login.
NVITEnd-user support

Commented:
Try this...

@echo off
set fnOut=%temp%\output.txt
>> "%fnOut%" echo Do not close this window till copy of files finish:  Thank you ICT Team
echo Do not close this window till copy of files finish:  Thank you ICT Team
>> "%fnOut%" echo xcopy...
xcopy "\\xxx.local\users\%username%\AppData\Google\chrome\Default\*.*" "%localappdata%\Google\Chrome\User Data\Default\" /q /s /e /i /y /c
>> "%fnOut%" echo %username% %date% %time%...
echo %username% %date% %time% >> \\xxx.local\users\reports\Chrome.txt
exit

Open in new window


After the user logs on, review %temp%\output.txt
Ajoy RajanManaged Service Consultant

Author

Commented:
The output script I removed the Do not close line and just tried with xcopy. The output.txt has xcopy… repeatedly. It just keeps going.
Ajoy RajanManaged Service Consultant

Author

Commented:
do you have a VBScript to which I might be able to use for this?
NVITEnd-user support

Commented:
> The output.txt has xcopy… repeatedly

Please post the whole script. You can change and sensitive info if needed.
Ajoy RajanManaged Service Consultant

Author

Commented:
The whole script is in my post above. That is all I am using for the script.

I need to make sure that the Chrome's default directory for every user is copied from the roaming profile into their local appdata. So that when we move the users to use chrome using the local appdata they do not find any difference.
NVITEnd-user support

Commented:
> The output.txt has xcopy… repeatedly

This confirms the batch file is running.

So the issue may be xcopy.

What about line 8? Is it creating Chrome.txt?
Ajoy RajanManaged Service Consultant

Author

Commented:
no it does not. As it is not going to run till the xcopy command is finished.
NVITEnd-user support

Commented:
> The output.txt has xcopy… repeatedly. It just keeps going.

How can you be certain?

Maybe xcopy is never finishing for some reason.

Have user manually run that exact xcopy command in a CMD window.
What is the result?
Ajoy RajanManaged Service Consultant

Author

Commented:
The xcopy command runs but I tried something. This may sound weird but, I ran the command in cmd and it worked fine. Then I converted the same command to batch file and it is not running the batch file.
NVITEnd-user support

Commented:
> Then I converted the same command to batch file and it is not running the batch file

Didn't you say in an earlier post the batch is running? Just the problem seems to be xcopy.

Are you now saying not the batch doesn't run at all?
Ajoy RajanManaged Service Consultant

Author

Commented:
I have been working on SCCM pushing the xcopy command and testing it at this stage.
Managed Service Consultant
Commented:
I used PDQ deploy to push the script to machines and worked like a charm.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial