Logon script not running

C

Carlos Pereira

Hi,

Hi,

I've got a small office network (one domain): Windows 2000 Server SP4
/ Windows XP Pro SP1

I am trying to implement small scripts for different tasks (I do not
have knowledge of VBS, I use MS-DOS BAT files).

I have created the following BAT file:

if exist "F:\%USERNAME%\Backup" (goto COPY) else mkdir
"F:\%USERNAME%\Backup"

:COPY
xcopy /d /s /e /r /h /o /y "D:\Files\*.*" "F:\%USERNAME%\Backup"
echo The job is finish
pause

F is a share of a folder located in a Windows 2000 Server. This unit
is permanently assigned to all users, therefore I do not need to
assign it through the script.

- If I run the script locally in my computer logged in with my domain
administrator account, it works fine.
- If I run the script locally in any other computer logging in with a
domain user account (not a domain administrator account), it does not
works. I get a Access denied message in MS-DOS. The folder is created
in the network share, and a file with 0 Kb is also created. No other
file or folders are created or copied.
- If I create a GPO for the domain (top level), assign the BAT file to
a logon script and login in any computer of the domain (even my
computer), the script does not run. I do not see any MS-DOS screen at
startup, no folder is created in the network share (or elsewhere), and
no error message appears. It seem like the batch file it does not run
at all.

I have tried with some sample VBS gathered from the Microsfot site,
and they work fine. They run as expected with any user account in any
computer.

I understand I have 2 different problems:

1.- For some reason I do not quite understand, the batch cannot copy
files from a local folder to a newtwork share, unless I use my
administrator account. However, if I open the command window and use
the COPY command, I can copy any file or folder to any network
location. Take into account that the domain users are local
administrators in their computers.
2.- My batch file does not run, but any other I have tried does.
Unfortunately, I do not know how to transfer this to a VBS script (if
it could help at all as a test).

NOTE: The batch file is assigned to the whole domain, to the user
configuration part of the GPO, not to the computer part. I am
positively sure that no other GPO is blocking or modifying this GPO
(you can easily tell this, because other scripts are working fine.).
All users logon to the domain, never locally (they do not have a local
account). All domain users account exists in their WK with local
administrator rights.

¿Can anybody give me a hand on this?

Thanks in advance and please excuse my ignorance on this issues

Carlos
 
P

Pegasus \(MVP\)

Carlos Pereira said:
Hi,

Hi,

I've got a small office network (one domain): Windows 2000 Server SP4
/ Windows XP Pro SP1

I am trying to implement small scripts for different tasks (I do not
have knowledge of VBS, I use MS-DOS BAT files).

I have created the following BAT file:

if exist "F:\%USERNAME%\Backup" (goto COPY) else mkdir
"F:\%USERNAME%\Backup"

:COPY
xcopy /d /s /e /r /h /o /y "D:\Files\*.*" "F:\%USERNAME%\Backup"
echo The job is finish
pause

F is a share of a folder located in a Windows 2000 Server. This unit
is permanently assigned to all users, therefore I do not need to
assign it through the script.

- If I run the script locally in my computer logged in with my domain
administrator account, it works fine.
- If I run the script locally in any other computer logging in with a
domain user account (not a domain administrator account), it does not
works. I get a Access denied message in MS-DOS. The folder is created
in the network share, and a file with 0 Kb is also created. No other
file or folders are created or copied.
- If I create a GPO for the domain (top level), assign the BAT file to
a logon script and login in any computer of the domain (even my
computer), the script does not run. I do not see any MS-DOS screen at
startup, no folder is created in the network share (or elsewhere), and
no error message appears. It seem like the batch file it does not run
at all.

I have tried with some sample VBS gathered from the Microsfot site,
and they work fine. They run as expected with any user account in any
computer.

I understand I have 2 different problems:

1.- For some reason I do not quite understand, the batch cannot copy
files from a local folder to a newtwork share, unless I use my
administrator account. However, if I open the command window and use
the COPY command, I can copy any file or folder to any network
location. Take into account that the domain users are local
administrators in their computers.
2.- My batch file does not run, but any other I have tried does.
Unfortunately, I do not know how to transfer this to a VBS script (if
it could help at all as a test).

NOTE: The batch file is assigned to the whole domain, to the user
configuration part of the GPO, not to the computer part. I am
positively sure that no other GPO is blocking or modifying this GPO
(you can easily tell this, because other scripts are working fine.).
All users logon to the domain, never locally (they do not have a local
account). All domain users account exists in their WK with local
administrator rights.

¿Can anybody give me a hand on this?

Thanks in advance and please excuse my ignorance on this issues

Carlos

As I pointed out when you posted your question in Spanish, you
have a syntax error in your batch file:

=================
Bad version:
if exist "F:\%USERNAME%\Backup" (goto COPY) else mkdir
"F:\%USERNAME%\Backup"

:COPY
xcopy /d /s /e /r /h /o /y "D:\Files\*.*" "F:\%USERNAME%\Backup"
echo The job is finished

=================
Better version:
if exist "F:\%USERNAME%\Backup" (goto COPY) else (mkdir
"F:\%USERNAME%\Backup")

:COPY
xcopy /d /s /e /r /h /o /y "D:\Files\*.*" "F:\%USERNAME%\Backup"
echo The job is finished

=================
Best version:
if not exist "F:\%USERNAME%\Backup" mkdir "F:\%USERNAME%\Backup"
xcopy /d /s /e /r /h /o /y "D:\Files\*.*" "F:\%USERNAME%\Backup"
echo The job is finished

=================

I suggest you take care of the syntax errors, then post again if you
still have problems.
 
C

Carlos Pereira

I have run the suggested script locally and assigned to a group policy
(logon script). Locally runs fine. The logon script, however, does not
run at all. No command screen is shown during start up, no directory
is created and no files are copied anywhere.

What could be wrong?

Thanks

Carlos
 
C

Carlos Pereira

Finally it works. The problem was one parameter of the xcopy command:
/c

After deleting this command, it works as it should in every computer.

Thank you very much for your help.

Carlos
 
P

Pegasus \(MVP\)

There are some contradictions here.
- In your first post today there was no /c switch.
- In your second post you said that removal of the /c switch fixed the
problem.
Was the switch there, or was it not?
- In your first post you said that the logon script did not run at all.
- In your second post you said that the script ran after you
removed the /c switch. Now we both know that the presence
or absence of a switch will modify the operation of the batch
file. It will NOT prevent the batch file from running.

If you want your logon script to run reliably then I suggest you
get to the bottom of these contradictions. You should also
investigate why the /c switch is necessary. Its purpose is to
continue on an error condition - but you should not have any
error conditions at all!
 
C

Carlos Pereira

Dear Pegassus,

There are some contradictions here.
- In your first post today there was no /c switch.
- In your second post you said that removal of the /c switch fixed the
problem.
Was the switch there, or was it not?

Sorry, I was referring to the /o switch
- In your first post you said that the logon script did not run at all.
- In your second post you said that the script ran after you
removed the /c switch. Now we both know that the presence
or absence of a switch will modify the operation of the batch
file. It will NOT prevent the batch file from running.

Well, I tried to run the script with all the switches. The script run
fine locally in my computer, with my domain administrator account and
administrative rights in the computer. It did not run locally in any
other computer loging in as any other domain user (not a domain
administrator account, no administrator rights in their computer). I
got the access denied error (not any other error), as I mentioned
before. I do not know the reason of this problem, but after deleting
the /o switch, it runs fine locally in any computer (I tried this test
after reading your response). Then, I tried assigning this batch file
(without the /o switch) to a GPO. It went fine.

I guess the /o switch was the one to blame, but I still do not
understand why.
If you want your logon script to run reliably then I suggest you
get to the bottom of these contradictions. You should also
investigate why the /c switch is necessary. Its purpose is to
continue on an error condition - but you should not have any
error conditions at all!

Please excuse me for messing you up.

Thanks again,

Carlos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top