Link to home
Start Free TrialLog in
Avatar of Ajoy Rajan
Ajoy RajanFlag for Australia

asked on

GPO applying but logon script not working

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
Avatar of NVIT
NVIT
Flag of United States of America image

Where on the gpo tree is the script running?
Avatar of Ajoy Rajan

ASKER

The ICT Operations team OU. It is linked to the right OU.
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?
It is in the user branch. Currently for ICT users.
Is your script added to: User Configuration > Windows Settings > Scripts > Logon
yes it is.
> ...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.
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.
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
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.
do you have a VBScript to which I might be able to use for this?
> The output.txt has xcopy… repeatedly

Please post the whole script. You can change and sensitive info if needed.
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.
> 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?
no it does not. As it is not going to run till the xcopy command is finished.
> 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?
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.
> 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?
I have been working on SCCM pushing the xcopy command and testing it at this stage.
ASKER CERTIFIED SOLUTION
Avatar of Ajoy Rajan
Ajoy Rajan
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial