Avatar of Ajoy Rajan
Ajoy Rajan
Flag 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
Windows Batch* grouppolicy

Avatar of undefined
Last Comment
Ajoy Rajan

8/22/2022 - Mon
NVIT

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

ASKER
The ICT Operations team OU. It is linked to the right OU.
NVIT

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?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Ajoy Rajan

ASKER
It is in the user branch. Currently for ICT users.
NVIT

Is your script added to: User Configuration > Windows Settings > Scripts > Logon
Ajoy Rajan

ASKER
yes it is.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
NVIT

> ...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 Rajan

ASKER
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.
NVIT

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
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Ajoy Rajan

ASKER
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 Rajan

ASKER
do you have a VBScript to which I might be able to use for this?
NVIT

> The output.txt has xcopy… repeatedly

Please post the whole script. You can change and sensitive info if needed.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Ajoy Rajan

ASKER
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.
NVIT

> 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 Rajan

ASKER
no it does not. As it is not going to run till the xcopy command is finished.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
NVIT

> 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 Rajan

ASKER
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.
NVIT

> 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?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Ajoy Rajan

ASKER
I have been working on SCCM pushing the xcopy command and testing it at this stage.
ASKER CERTIFIED SOLUTION
Ajoy Rajan

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question