Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

example logon scripts for default printer in Off97 (Novell, NT/Citrix)

Status
Not open for further replies.

sjr

IS-IT--Management
Apr 8, 2001
5
NL
Hi,

This message is intended for TheOtherKiwi.

Thank you for your reply on my thread with regard to 'no default printer in Office97 (Novell, Citrix/NT, NDS for NT).

Unfortunately I do not have your E-mail address so I hope you will respond to this new thread. Please mail me examples of logon scripts (NT or NetWare).
E-mail:S.Riemens@div.nl

I am looking forward to your early reply.

Thanks,

 
Hey Kiwi... if ya dont mind I'd love to check out your script too... always happy to look at other peoples ideas and see what stuff I can fleece *cough* borry out of it...

email is stephen.marshall@exprogroup.com

Thanks in advance

Steve Marshall
Group IT
Technical Support Supervisor
(aka General Meddler)
The Expro Group
Reading
UK
 
I'll search my archive when I get home tonight (thats NZ time!) and forward a couple of juicy examples...
 
Heres one I put together for a win2k box...

' Create WSH objects and populate with data from the Domain/AD
set wshNetwork = WScript.CreateObject("WScript.Network")
set wshShell = WScript.CreateObject("WScript.Shell")

' Wait for up to 30 seconds for the user-specific data to be located and loaded from Domain/AD
HurryUp = Timer + 30
Do
Wscript.Sleep 100 ' Check every 100mS
Loop until wshNetwork.username <> &quot;&quot; or HurryUp < Timer
If wshNetwork.username=&quot;&quot; then ProblemGettingDomainData

' Set some variables
User = wshNetwork.username
Domain = wshNetwork.userdomain
computer = wshNetwork.computername

' Determine the users Domain/AD Group membership
adspath=&quot;WinNT://&quot; & domain & &quot;/&quot; & user

' Create an object and populate it with user account properties from the Domain/AD
set adsobj = getobject(adspath)


' Map Drives based on Group Membership
' Users can belong to many groups. The group name for every group that the user belongs to is
' passed through a &quot;select case&quot; test. If the group name under test matches any &quot;case&quot; statement,
' then the line(s) under the &quot;case&quot; statement is actioned.

' The checkNetworkMapping(&quot;x:&quot;) is a function used to check if a drive is already mapped to the
' requested drive letter. It returns False if the letter is available.

' The mapNetwork subroutine will map a drive letter to a UNC path. If the path is invalid or
' unavailable, the routine will popup a warning message for 3 seconds then carry on.


for each prop in adsobj.groups ' Cycle through the user's group membership list

select case prop.name ' Pass the name of the group through the following filter

case &quot;groupname&quot; ' User is a member of this group so...
'if checkNetworkMapping(&quot;S:&quot;) = false then mapNetwork &quot;S:&quot;, &quot;\\servername\sharename&quot;

case &quot;printergroupname&quot; ' User is a member so map printer...
mapPrinter &quot;\\printservername\printsharename&quot;
defPrinter &quot;\\printservername\printsharename&quot;

end select ' Finish the filter test for this group name

next ' Loop around until every entry in the group membership list has been tested

' Sub Routines and Functions called by the master script

function checkNetworkMapping(Driveletter)
' See if the drive letter is already mapped
dim drive
checkNetworkMapping = false
for each Drive in wshNetwork.enumNetworkDrives
if LCase(Drive) = LCase(DriveLetter) then
CheckNetworkMapping = True ' Drive already mapped
Exit For
end if
next
end function

sub mapNetwork(driveletter, netshare)
' Map a drive
on error resume next ' If mapping fails then carry on
err.clear
wshNetwork.mapNetworkDrive driveletter, netshare, false
if err <> 0 then
' Drive mapping failed, display a popup message window for 2 seconds
ignore = WshShell.Popup(&quot;Error Mapping Drive &quot; + driveletter , 2, &quot;Imperial Tobbaco New Zealand&quot;, 48)
end if
end sub

Sub mapPrinter(prnshare)
On Error Resume Next
err.clear
WshNetwork.AddWindowsPrinterConnection prnshare
if err <> 0 then
' printer share failed, display a popup message window for 2 seconds
ignore = WshShell.Popup(&quot;Printer &quot; + prnshare + &quot; already connected.&quot;, 2, &quot;Imperial Tobbaco New Zealand&quot;, 48)
end if
End Sub

Sub defPrinter(pshare)
' On Error Resume Next
' err.clear
' WshNetwork.SetDefaultPrinter pshare
' if err <> 0 then
' ' printer share failed, display a popup message window for 2 seconds
' ignore = WshShell.Popup(&quot;Default printer already mapped &quot; + pshare , 2, &quot;Imperial Tobbaco New Zealand&quot;, 48)
' end if
End Sub

sub ProblemGettingDomainData
' Couldn't get the Domain/AD data within 30 seconds
wscript.Echo &quot;Failed to access Domain/AD account data&quot;
Wscript.Quit ' Quit
end sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top