#173784 - 2007-02-08 10:11 PM
Script won't run at login, but runs from the command line
|
LANSonic
Lurker
Registered: 2007-02-08
Posts: 3
|
I am a complete noob to scripting so, please, bear with me. My boss wants a script to migrate all users to a new print server with the same printers on both; only the server name changes. I found one named QCHANGE.VBS that seems to work fine. When I put it in the KiX login script it won't run (I get no errors either). When I execute the same script manually from the Run command it works fine.
Code _______________________________________________________________ IF INGROUP("Domain Printer Test")=1 ; All users in the test group shell "cscript.exe //nologo qchange.vbs changes.txt" ENDIF _______________________________________________________________ End Code
Any ideas? Note: I am completely open to other ways to make this change that do not involve user interaction!
|
|
Top
|
|
|
|
#173785 - 2007-02-08 11:01 PM
Re: Script won't run at login, but runs from the command line
[Re: LANSonic]
|
Witto
MM club member
   
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
A few weeks ago, the same question was asked. I think PriMapState() can help you. Adding/removing network printers
|
|
Top
|
|
|
|
#173806 - 2007-02-09 05:14 PM
Re: Script won't run at login, but runs from the command line
[Re: Witto]
|
Witto
MM club member
   
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
Just a thought, I do not know if it would be tricky, but maybe you can enumerate all the ShareName keys under HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers and save them to a text file to avoid typo errors...
;************************************************************************* ; Script Name: CreatePrinterList.kix ; Author: Wim Rotty ; Date: 9/02/2007 ; Description: List all printer sharenames on printer server ;*************************************************************************
;Script Options If NOT @LOGONMODE Break On Else Break Off EndIf DIM $RC $RC = SetOption("Explicit","On") $RC = SetOption("NoVarsInStrings","On") $RC = SetOption("NoMacrosInStrings","On") $RC = SetOption("WrapAtEOL","On")
;Redirect Screen Output to file $RC = RedirectOutput(@SCRIPTDIR+"\printers.txt")
;Declare vars DIM $RKyLocalPrinters, $SharedPrinters, $Printer, $i, $Separator $RKyLocalPrinters = "\\PRTSERVER\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers" $Separator = "," $i = 0
;Enumerate all local printers on server $Printer = EnumKey($RKyLocalPrinters, $i) While NOT @ERROR If NOT $SharedPrinters = "" $SharedPrinters = $SharedPrinters + $Separator EndIf ;Find ShareName and add it to list $SharedPrinters = $SharedPrinters + ReadValue($RKyLocalPrinters+"\"+$Printer+"\DsSpooler","printShareName") $i = $i + 1 $Printer = EnumKey($RKyLocalPrinters, $i) Loop $SharedPrinters ? |
This will save you a list named printers.txt in your scripting directory.
|
|
Top
|
|
|
|
#173892 - 2007-02-13 05:20 PM
Re: Script won't run at login, but runs from the command line
[Re: Witto]
|
LANSonic
Lurker
Registered: 2007-02-08
Posts: 3
|
Thank you to all who have provided help, but a coworker and I solved the problem. When the script ran at login it was defaulting to my home drive when looking for the VBScript, which obviously was not there. When we modified the KIX script to include the full path to VBScript it worked perfectly. Here's the final code: Code ______________________________________________________________________ ; Remaps printers to the new print server TEH 2/6/2007 IF INGROUP("Domain Printer Test")=1 ; All users in the test group shell "cscript.exe //nologo \\myserver\netlogon\qchange.vbs \\myserver\netlogon\changes.txt" ENDIF ______________________________________________________________________
Thank you again.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1183 anonymous users online.
|
|
|