Solved

question: why isn't this login script working?

Posted on 2009-04-10
3
362 Views
Last Modified: 2012-05-06
as a preface, I haven't really done much with startup / login scripts before so if I sound like an idiot, try not to judge.

Here is the script, as it was when I first checked it out. My goal was to add code to add a newtworked printer when users log in, because whenever someone logs onto a computer they haven't logged on to here before, they don't get the printer. So I have to go around setting it up for them each time they use a new computer. Anyways the BOLD TEXT is what I added, based on some online research.

[code]
[B]Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection "\\DCNAME\Canon 2010f"[/B]

net use p: \\DCNAME\public
net use s: \\DCNAME\scans
net use t: \\DCNAME\clientapps

:quickbooks
ifmember quickbooks
if not errorlevel 1 goto end
net use q: \\DCNAME\quickbooks

end

\\DCNAME\sysvol\DOMAIN.local\scripts\SBS_LOGIN_SCRIPT.bat
[/code]

Basically I just added the top two lines. Now I tested it out by saving the new code as script2.bat in the same directory, going into Active Directory, and changing the login script for one user from script.bat (the original) to script2.bat (my new one). I then went to the user's workstation and removed the printer in question (logged on as the user of course), logged out, and logged back on. The shares still get set up correctly but no printer.

Any ideas?? Thanks!
0
Comment
Question by:Mizugori44
3 Comments
 
LVL 83

Accepted Solution

by:
oBdA earned 120 total points
ID: 24115598
It isn't working because the lines you've inserted are VB script, not batch.
Easiest workaround for the time being: save these lines as Printers.vbs in the folder where your logon script already is, then add the following line to the logon script instead of these lines:

cscript /nologo "%~dp0Printers.vbs"

cscript /nologo "%~dp0Printers.vbs"
net use p: \\DCNAME\public
net use s: \\DCNAME\scans
net use t: \\DCNAME\clientapps
 
:quickbooks
ifmember quickbooks
if not errorlevel 1 goto end
net use q: \\DCNAME\quickbooks
 
end
 
\\DCNAME\sysvol\DOMAIN.local\scripts\SBS_LOGIN_SCRIPT.bat

Open in new window

0
 
LVL 5

Expert Comment

by:mrmarkfury
ID: 24115611
Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection "\\DCNAME\Canon 2010f"

The preceding is for a .vbs script, not a .bat script as far as I know.

Try creating a .vbs in notepad, adding the two lines, and then linking that .vbs to run after the .bat.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

So you have two Windows Servers and you have a directory/folder/files on one that you'd like to mirror to the other?  You don't really want to deal with DFS or a 3rd party solution like Doubletake. You can use Robocopy from the Windows Server 200…
I've always wanted to allow a user to have a printer no matter where they login. The steps below will show you how to achieve just that. In this Article I'll show how to deploy printers automatically with group policy and then using security fil…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question