We help IT Professionals succeed at work.

GPO applying but logon script not working

Ajoy Rajan
Ajoy Rajan asked
on
157 Views
Last Modified: 2019-02-03
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

NVITEnd-user support
CERTIFIED EXPERT

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
CERTIFIED EXPERT

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?
Ajoy RajanManaged Service Consultant

Author

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

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

Author

Commented:
yes it is.
NVITEnd-user support
CERTIFIED EXPERT

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
CERTIFIED EXPERT

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
CERTIFIED EXPERT

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
CERTIFIED EXPERT

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
CERTIFIED EXPERT

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
CERTIFIED EXPERT

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:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions