Batch File as Login Script


D

Don I

I've got a batch file assigned as the loginscript for every user in my
office.

For some reason, it runs FIRST HALF the script but not the SECOND HALF. I'm
just not seeing a reason for it--can anyone else? I marked in the code
below where the last line that I can confirm actually works is.

TIA

==================================
@echo off
if %COMPUTERNAME%.==servername. goto end
call \\servername\netlogon\RemDrives.bat
call \\servername\netlogon\RemPrinters.bat
start /wait \\servername\netlogon\login.vbs

\\servername\netlogon\showmbrs "\\servername\IT" | find "%username%" /i>nul
if not errorlevel 1 start \\servername\netlogon\ITlogin.vbs /w

rem is the user in mgmt?
\\servername\netlogon\showmbrs "\\servername\mgmt" | find "%username%"
/i>nul
if not errorlevel 1 goto Mgmt
rem is the user in ProjMgmt?
\\servername\netlogon\showmbrs "\\servername\ProjMgmt" | find "%username%"
/i>nul
if not errorlevel 1 goto ProjMgmt
goto NotMgmtPM

:Mgmt
start \\servername\netlogon\mgmtlogin.vbs /w
:projMgmt
start \\servername\netlogon\mktlogin.vbs /w
start \\servername\netlogon\Invlogin.vbs /w

:NotMgmtPM
:checkport1
rem start /wait \\servername\netlogon\p24.vbs



Rem The next line is the last one that I can confirm actually runs
successfully.
start /wait \\servername\netlogon\Port2.vbs
:Audit
rem goto AuditDone
IF NOT EXIST \\servername\tkfree\SCAN\HSLAUNCH.EXE GOto AuditDone
c:
cd \
if exist o:\*.* NET USE O: /DELETE>nul
if not exist o:\SCAN\HSLAUNCH.EXE Net use O: \\servername\tkfree>nul
start /wait o:\SCAN\HSLAUNCH.EXE O:\SCAN>nul
c:
cd\
rem goto AuditDone
if not exist o:\SCAN\HSLAUNCH.EXE goto AuditDone
rem net use o: /d /y>nul
:AuditDone
echo This is a test. %computername%>c:\machinetest.list

goto end
if exist \\servername\bat\set_ustnJ.bat call \\servername\bat\set_ustnJ.bat
if exist \\servername\bat\set_ustnV8.bat call
\\servername\bat\set_ustnV8.bat
if exist \\servername\bat\NavUp.bat call \\servername\bat\NavUp.bat
if exist \\servername\bat\VSUpdate.bat call \\servername\bat\VSUpdate.bat
if exist \\servername\bat\do_once.bat call \\servername\bat\do_once.bat


:end
if exist \\servername\bat\SetV8License.bat \\servername\bat\SetV8License.bat
cls
if NOT %COMPUTERNAME%.==PC65. NET TIME \\PC65 /SET /Y
if exist \\servername\bat\set_ustnJ.bat call \\servername\bat\set_ustnJ.bat
if exist \\servername\bat\set_ustnV8.bat call
\\servername\bat\set_ustnV8.bat
 
Ad

Advertisements

M

Michael Bednarek

I've got a batch file assigned as the loginscript for every user in my
office.

For some reason, it runs FIRST HALF the script but not the SECOND HALF. I'm
just not seeing a reason for it--can anyone else? I marked in the code
below where the last line that I can confirm actually works is.

TIA

==================================
@echo off [snip]

Rem The next line is the last one that I can confirm actually runs
successfully.
start /wait \\servername\netlogon\Port2.vbs
[snip]

What's in \\servername\netlogon\Port2.vbs ? And are you sure that the
vbs extension is associated with what you think it is? On our systems,
the default action for vbs is mostly Notepad, on my own workstation it's
Textpad; nowhere here is the default action CSCRIPT/WSCRIPT.

What happens if you run that single command interactively on a
workstation?
 
Ad

Advertisements

A

Al Dunbar [MS-MVP]

Michael Bednarek said:
I've got a batch file assigned as the loginscript for every user in my
office.

For some reason, it runs FIRST HALF the script but not the SECOND HALF. I'm
just not seeing a reason for it--can anyone else? I marked in the code
below where the last line that I can confirm actually works is.

TIA

==================================
@echo off [snip]

Rem The next line is the last one that I can confirm actually runs
successfully.
start /wait \\servername\netlogon\Port2.vbs
[snip]

What's in \\servername\netlogon\Port2.vbs ? And are you sure that the
vbs extension is associated with what you think it is? On our systems,
the default action for vbs is mostly Notepad, on my own workstation it's
Textpad; nowhere here is the default action CSCRIPT/WSCRIPT.
Since you have many other START commands, some with /wait, some without, it
seems safe to assume that .vbs is appropriately handled. But does it use
cscript or wscript?

Because your script has conditionals whose conditions we are not able to
test without access to your infrastructure, it is similarly difficult to
determine what other statements are being executed. You do not specify how
you know that this statement executes, so I will assume that it is because
at least some of the tasks of the .vbs being run are being carried out. Are
ALL of those tasks being done? Does that particular script perhaps fail to
terminate, thereby making the /wait somewhat infinite in duration?

In order to be sure where in the batch file it gets hung, I would recommend
a batch-only method: place statements like this before and after each
command in the batch file:
%temp%\battest.txt echo/tracepoint number 1
incrementing the "tracepoint number". You then logon and examine the
temporary text file to see how far the script got.


Once you get this little detail ironed out, I would recommend that you
consider re-coding your logon script in a single scripting language, whether
batch or WSH. As it is, your logic is scattered across a number of separate
scripts in the two languages, which I know from experience, makes it a
little harder to debug.

I'd also suggest that, instead of hard-coding the netlogon share part of the
path to those .bat and .vbs files, you locate them all relative to where the
main logon script is, for example, instead of:

call \\servername\netlogon\RemDrives.bat

do this:

call %0\..\RemDrives.bat

This will make it easier to test all of the code before you commit it to the
domain controller.

/Al
 

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