set default printer in terminal server script



Hi
Windows 2003 En terminal sever
Windows 2000 Pro clients
Windows 2000 native domain
Maybe some one can help
I try set default printer with logon script
problem is that script set default printer (installed local on terminal
server) after ~30s
If pause is smaler i get error some like printer name not found or ect. I
try diferent metods to set printers but result are the same
Marius

PS.: Script set default printer based on client computer group membership

On error resume next
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1
pr1="1printer"
pr2="2printer"
Set objNetwork = CreateObject("Wscript.Network")
server = objNetwork.ComputerName
Set ADSysInfo = CreateObject("ADSystemInfo")
Set Sh=WScript.CreateObject("WScript.Shell")
Set CurrentUser = GetObject("LDAP://"; & ADSysInfo.UserName)
Clientname=Sh.ExpandEnvironmentStrings("%Clientname%")
Set objShell = CreateObject("Wscript.Shell")
strNetBIOSDomain = objShell.Environment("Process").Item("userdomain")
strDomain = strNetBIOSDomain
strComputer = clientname
Set objTrans = CreateObject("NameTranslate")
objTrans.Init ADS_NAME_INITTYPE_GC, ""
objTrans.Set ADS_NAME_TYPE_NT4, strDomain & "\" & strComputer & "$"
strComputerDN = objTrans.Get(ADS_NAME_TYPE_1779)
Set objComputer = GetObject("LDAP://"; & strComputerDN)
Set colGroups = objComputer.Groups
wscript.sleep 30000 '<---if i change this to 25000 error come out
For Each objGroup in colGroups
If objGroup.cn=pr1 Then
Set objWMIService = GetObject ("winmgmts:\\" & server &_
"\root\cimv2:Win32_Process")
objWMIService.Create("rundll32 printui.dll,PrintUIEntry /y_
/n\\"&server&"\HP2000C")'
ElseIf objGroup.cn=pr2 Then
Set objWMIService = GetObject ("winmgmts:\\" & server &_
"\root\cimv2:Win32_Process")
objWMIService.Create("rundll32 printui.dll,PrintUIEntry /y_
/n\\"&server&"\HP2500C")'
End If
Next


.



Relevant Pages

  • Re: login scripting
    ... unless you're using Windows 98 or something equally ... horrid on the clients. ... > applications that are in the startup group load with no problems. ... > Once the login script completes, the apps load fine, however the users are ...
    (microsoft.public.win2000.general)
  • Re: login script not working for win2k
    ... Are the Windows XP and Windows 2000 clients located at different sites? ... Default Domain Policy? ... did not get the script, run "gpresult /z> gpresult.txt" from the command ...
    (microsoft.public.windows.group_policy)
  • INSTALL Application via logon script
    ... I have Windows 2003 Active directory deployed. ... clients are Windows 2002 XP Pro. ... machine doesnt have administrative prilivages on their ... I have created a script that installs a particular ...
    (microsoft.public.win2000.active_directory)
  • Re: Logon script for printers
    ... Create a batch file containing lines of the following ... Configure a logon script policy. ... a Windows Explorer dialogue and copy your batch file to this directory. ... 2000 clients, it takes a little longer for Windows XP clients. ...
    (microsoft.public.windows.server.scripting)
  • Re: Microsoft Warns of New Windows Flaw (March 19, 2003 )
    ... In WINDOWS SETUP in ADD/REMOVE PROGRAMS of Control Panel ... Uninstall Outlook Express, ... Java, Javascript, ActiveX and all the other script runner toys Billy ... Install WebWasher the spammers are terrified of free from ...
    (comp.security.misc)