Page 1 of 2 12>
Topic Options
#43336 - 2003-07-25 08:57 AM Help with printer script - revised
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11601
Loc: CA
Howard,

Please close the other TOPICS. It is a Starters question, not a General,
and I can't use POST PREP in the General forum. [Wink]

Rbardo,

LOGON.BAT
code:
@ECHO OFF
net time \\mail /set /y
%0\..\WKix32.exe /i /d %0\..\KIXTART.KIX

Here is an attempt at cleaning up your script some. I have not reviewed or
confirmed that any of it works. You need to review and test yourself.

If you DO NOT have any Windows 9x systems to support you do not need
to use the %0\..\ parameters for the calling script. You can simply
run WKIX32.EXE KIXTART.KIX
and your NT/2000/XP/2003 systems will run KiXtart just fine.
Also, you would not want to run the /d DEBUG switch with a production script
it is only used to help track down problems with the script.

By default, KiXtart automatically looks for a personal script for the
current user ("Username.KIX"). If it does not find one, it looks for
the default script, "KIXTART.KIX". You can override this behavior by
specifying one or more scripts after Kix32.exe on the commandline

Copy the code below and save it as KIXTART.KIX and place it into your NETLOGON
folder. Then set your clients to run WKIX32.EXE KIXTART.KIX (for NT systems)
Windows 9x does require the %0\..\ in a batch file.






IF @INWIN=1 ; Excludes all Windows 9x systems
IF LocalAdmin ; Only runs if the user has Local workstation admin rights
; Most installers and uninstallers will not run if the user
; does not have Admin rights
$CheckWS=ReadValue('HKLM\Software\MyCompany\WS', 'RANUNINSTALLER')
IF $CheckWS <> 1
IF EXIST('%ProgramFiles%\OfficeView Pro\uninstWS.exe')
SHELL '%COMSPEC% /C %ProgramFiles%\OfficeView Pro\uninstWS.exe /S'
$MarkWS=WRITEVALUE('HKLM\Software\MyCompany\WS', 'RANUNINSTALLER', '1', 'REG_SZ')
; Mark the registry so that this program does not run every time the user logs in
ENDIF
ENDIF
; I assume you are running this PC Asset Navigator program
; http://www.a-navigator.com/an/index.html
USE W: /DELETE /PERSISTENT
USE W: '\\holdem\asset_db$'
SHELL SHELL '%COMSPEC% /C W:\ina32.exe'
USE W: /DELETE /PERSISTENT
ENDIF
ENDIF


; The rest of the script will run for all systems including Windows 9x

USE J: /DELETE /PERSISTENT
USE J: '\\terminal\slip_stream'
$MyDox = '%COMSPEC% /C REGEDIT /S j:\registry\mydox.reg >nul 2>nul'
$HideC = '%COMSPEC% /C REGEDIT /S j:\registry\hide_c.reg >nul 2>nul'
$Outlook = '%COMSPEC% /C REGEDIT /S j:\registry\outlook.reg >nul 2>nul'
; Not sure what this does, but KiX can do all the registry edits natively
USE J: /DELETE /PERSISTENT

use g: '\\ntbaksrv\common'
use i: '\\ntbaksrv\prod'
use k: '\\ntbaksrv\service'
use m: '\\ntserver\sdpcmrpw'
use o: '\\royal\mis'
use y: '\\terminal\share_point'
; use Z: /home ; Don't use this. Map it via the User Manager or AD tools
; Windows 9x Can Not map the Z: drive as the redirector uses this
; drive during the logon process

SHELL '%COMSPEC% /C \\Ntbaksrv\NETLOGON\use.exe'
; The shell command waits until the program completes before returning to the script

; No need to run Printers.kix as a seperate file unless you really want to

;printers.kix:
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dim $priReg, $x, $i, $rc, $ps
$loc='HKEY_CURRENT_USER\Network\LPT1'
$reg='HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion'
$dev=$reg+'\Devices'
$nprt=split(READVALUE($reg+'\Windows','Device'),',')[0]
$sysdrv=SUBSTR('%WINDIR%',1,2)

IF EXIST('H:')
$ps='H:\Scripts_DO_NOT_DELETE'
ELSE
$ps=$sysdrv+'\Scripts'
ENDIF
IF 0=EXIST($ps)
MD $ps
ENDIF
$ps=$ps+'\Printsetup.ini'

$i=0
DO
IF '\\'=LEFT($x,2)
$priReg=$priReg+$x
ENDIF
$x=ENUMVALUE($dev,$i)
$i=$i+1
UNTIL @error

IF LEN($priReg)
$rc=WRITEPROFILESTRING($ps,'Printers','','')
$priReg=split($priReg,'\\')
FOR $i=1 to ubound($priReg)
$rc=WRITEPROFILESTRING($ps,'Printers',$i,'\\'+$priReg[$i])
NEXT
ENDIF

SELECT
CASE INSTR($nprt,'\\') ;WRITE THE DEFAULT PRINTER TO THE CONFIG
$rc=WRITEPROFILESTRING($ps,'Printers','Default',$nprt)
USE LPT1: /delete /persistent
USE LPT1: $nprt /persistent
CASE $nprt='' AND EXIST($ps) ;NO DEFAULT PRINTER, LOAD PRINTERS FROM SAVED INFO
FOR EACH $key IN split(readprofilestring($ps,'Printers',''),chr(10))
$nul=addprinterconnection(readprofilestring($ps,'Printers',$key))
NEXT
$nprt=READPROFILESTRING($ps,'Printers','Default')
$rc=SETDEFAULTPRINTER($nprt)
USE LPT1: $nprt /persistent
CASE NOT INSTR($nprt,'\\') ;LOCAL PRINTER DEFAULT, SO WE WANT TO REMOVE NETWORK MAPPING
USE LPT1: /delete /persistent
ENDSELECT

function LocalAdmin()
$LocalAdmin=ingroup('@wksta\'+sidtoname('S-1-5-32-544'))-1+@inwin
endfunction


Top
#43337 - 2003-07-25 03:49 PM Re: Help with printer script - revised
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
Synchronizing time requires at least 'Power User' privileges, time synchronization in Windows NT/AD domain should rather be achieved through the Windows Time Service.

[ 25. July 2003, 18:23: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#43338 - 2003-07-25 06:19 PM Re: Help with printer script - revised
rbardo Offline
Fresh Scripter

Registered: 2003-07-24
Posts: 47
Loc: USA
You guys are the best!!!

Thanks a lot, I appreciate it. It helps so much! Now I have learned so much as well...

Sorry for not following initial procedure for submittal. Im new and it will be correct next time.

Thanks again.

Rob
_________________________
Ekadanta Mahakaya Surya koti samaprabha Nirbighnam kurume deva sarbakaryeshu sarbada

Top
#43339 - 2003-07-25 07:37 PM Re: Help with printer script - revised
rbardo Offline
Fresh Scripter

Registered: 2003-07-24
Posts: 47
Loc: USA
Hey NTDOC,

Im gonna peruse through here and look for some registry hack code help, but per your question in the code you assisted me with... Here is what the reg keys do..

code:
 Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoDriveTypeAutoRun"=dword:00000095
"NoDrives"=dword:0000001f

and
code:
 Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders]
"AppData"="C:\\Documents and Settings\\adam\\Application Data"
"Cookies"="C:\\Documents and Settings\\adam\\Cookies"
"Desktop"="C:\\Documents and Settings\\adam\\Desktop"
"Favorites"="C:\\Documents and Settings\\adam\\Favorites"
"NetHood"="C:\\Documents and Settings\\adam\\NetHood"
"Personal"="z:\\"
"My Pictures"="z:\\My Pictures"
"PrintHood"="C:\\Documents and Settings\\adam\\PrintHood"
"Recent"="C:\\Documents and Settings\\adam\\Recent"
"SendTo"="C:\\Documents and Settings\\adam\\SendTo"
"Start Menu"="C:\\Documents and Settings\\adam\\Start Menu"
"Templates"="C:\\Documents and Settings\\adam\\Templates"
"Programs"="C:\\Documents and Settings\\adam\\Start Menu\\Programs"
"Startup"="C:\\Documents and Settings\\adam\\Start Menu\\Programs\\Startup"
"Local Settings"="C:\\Documents and Settings\\adam\\Local Settings"
"Local AppData"="C:\\Documents and Settings\\adam\\Local Settings\\Application Data"
"Cache"="C:\\Documents and Settings\\adam\\Local Settings\\Temporary Internet Files"
"History"="C:\\Documents and Settings\\adam\\Local Settings\\History"
"Fonts"="C:\\WINNT\\Fonts"
"Administrative Tools"=""

and
code:
 Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Outlook\Security]
"Level"=dword:00000003
"UseCRLChasing"=dword:00000001
"Level1Remove"="txt;gif;html;htm"

whats my best bet for kix scripts to do natively as you stated...?
_________________________
Ekadanta Mahakaya Surya koti samaprabha Nirbighnam kurume deva sarbakaryeshu sarbada

Top
#43340 - 2003-07-25 07:42 PM Re: Help with printer script - revised
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
This can all be done natively via WRITEVALUE.
However, what is the point of redirecting the user shell folders to the same loction as where they normally would be, assuming a username of 'adam' ?
_________________________
There are two types of vessels, submarines and targets.

Top
#43341 - 2003-07-25 08:16 PM Re: Help with printer script - revised
rbardo Offline
Fresh Scripter

Registered: 2003-07-24
Posts: 47
Loc: USA
true true..

I actually want to edit the registry with these key values for any and all users on the box.
(not just adam, example only)

how can i edit these key values for any and all users??

I will look up the writevalue command in mean time.. This stuff is fun, i think once I learn it all I will kick a$$$$$$... [Big Grin]

thanks for help!
_________________________
Ekadanta Mahakaya Surya koti samaprabha Nirbighnam kurume deva sarbakaryeshu sarbada

Top
#43342 - 2003-07-25 08:31 PM Re: Help with printer script - revised
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
I can see why you want to edit the first and last section, but what is the purpose of the second section? [Confused]

You would edit these registry settings in the login script. Also, you would do WRITEVALUE just for
quote:
"Personal"="z:\\""
My Pictures"="z:\\My Pictures"

in the second section.
_________________________
There are two types of vessels, submarines and targets.

Top
#43343 - 2003-07-25 10:13 PM Re: Help with printer script - revised
rbardo Offline
Fresh Scripter

Registered: 2003-07-24
Posts: 47
Loc: USA
THis makes the users "my documents" folder default to the mapped "home" Z: drive on the server where we want to centralize all user saved files.. (not on the local hard drive)

--Z: is mapped through domain manager settings.
_________________________
Ekadanta Mahakaya Surya koti samaprabha Nirbighnam kurume deva sarbakaryeshu sarbada

Top
#43344 - 2003-07-25 10:21 PM Re: Help with printer script - revised
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
You will also have to remap the default storage for all Office programs and other applications that use their own defaulty settings.
_________________________
There are two types of vessels, submarines and targets.

Top
#43345 - 2003-07-25 11:23 PM Re: Help with printer script - revised
rbardo Offline
Fresh Scripter

Registered: 2003-07-24
Posts: 47
Loc: USA
Ok, thanks for the fyi sealeopard. I will look into that further.

Could you all please help me with my current script? Please look where I put a message in for help area.

code:
 ;===============================================================================================
;**** Created with KiXscripts Editor | http://KiXscripts.com ****
;**** Last Modified on 7/25/2003 at 2:17:56 PM by rbardo ****
;===============================================================================================


If @INWIN=1 ; Excludes all Windows 9x systems
If LocalAdmin ; Only runs if the user has Local workstation admin rights
; Most installers and uninstallers will not run if the user
; does not have Admin rights
$CheckWS=ReadValue('HKLM\Software\MyCompany\WS', 'RANUNINSTALLER')
If $CheckWS <> 1
If Exist('%ProgramFiles%\OfficeView Pro\uninstWS.exe')
Shell '%COMSPEC% /C %ProgramFiles%\OfficeView Pro\uninstWS.exe /S'
$MarkWS=WriteValue('HKLM\Software\MyCompany\WS', 'RANUNINSTALLER', '1', 'REG_SZ')
; Mark the registry so that this program does not run every time the user logs in
EndIf
EndIf
; I assume you are running this PC Asset Navigator program
; http://www.a-navigator.com/an/index.html
Use W: /DELETE /PERSISTENT
Use W: '\\holdem\asset_db$'
Shell '%COMSPEC% /C W:\ina32.exe'
Use W: /DELETE /PERSISTENT
EndIf
EndIf


; I need help from here
; I am trying to get the sid to use in the next function
; I am not sure how to pass the information gathered here to the next function
;ie: the users name


Break on
$SID = GetSID("WinNT://ff/lligetfa,USER")
? $SID

Get $_
Exit 1
;
;Source
Function GetSID($adspath)

Dim $rev,$sidobj,$sid,$sac,$x
$GetSID=0

$sidobj=CreateObject("adssid")
$sidobj.setas(5,$adspath)
$sid=$sidobj.getas(1)

If NOT $sid
$sidobj=0
Return
EndIf

$Rev=Val(SubStr($sid,1,2))

; Extract the SubAuthority Count (SAC) from the SID (range of 1 - 8, hence no hex conversion necessary)
$SAC=Val(SubStr($sid,3,2))
$IdentAuth=Val("&"+SubStr($sid,5,12))
$GetSID="S-"+$Rev+"-"+$IdentAuth

; Convert SID little-endian, just re-reverse the bytes and convert to decimal...
; Recurse as per SAC
For $X=1 to $SAC
$GetSID=$GetSID+"-"+Val("&"+SubStr($sid,8*$X+15,2)+SubStr($sid,8*$X+13,2)+SubStr($sid,8*$X+11,2)+SubStr($sid,8*$X+9,2))
Next

$sidobj=0

EndFunction


Function updateregistry($HKEY_CURRENT_USER, $Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders, $Personal=z:\\)
Dim $currentregvalue, $currentregtype, $rc $updateregistry=0
If $regtype='' $regtype='REG_SZ'
EndIf $currentregtype=ReadType($regsubkey,$regentry) $currentregvalue=ReadValue($regsubkey, $regentry)
If $currentregvalue<>$regvalue OR $currentregtype<>$regtype $rc=WriteValue($regsubkey,$regentry,$regvalue,$regtype)
If @ERROR
Exit @ERROR
EndIf $updateregistry=1
EndIf
Exit @ERRORendfunction
Function updateregistry($HKEY_CURRENT_USER, $Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders, $My Pictures=z:\\My Pictures)
Dim $currentregvalue, $currentregtype, $rc $updateregistry=0
If $regtype='' $regtype='REG_SZ'
EndIf $currentregtype=ReadType($regsubkey,$regentry) $currentregvalue=ReadValue($regsubkey, $regentry)
If $currentregvalue<>$regvalue OR $currentregtype<>$regtype $rc=WriteValue($regsubkey,$regentry,$regvalue,$regtype)
If @ERROR
Exit @ERROR
EndIf $updateregistry=1
EndIf
Exit @ERRORendfunction

; to here...
; I know the code is there twice but i dont know how to nest and i needed to change two values as you can see




; The rest of the script will run for all systems including Windows 9x

Use J: /DELETE /PERSISTENT
Use J: '\\terminal\slip_stream'
$MyDox = '%COMSPEC% /C REGEDIT /S j:\registry\mydox.reg >nul 2>nul'
;$HideC = '%COMSPEC% /C REGEDIT /S j:\registry\hide_c.reg >nul 2>nul'
$Outlook = '%COMSPEC% /C REGEDIT /S j:\registry\outlook.reg >nul 2>nul'
; Not sure what this does, but KiX can do all the registry edits natively
Use J: /DELETE /PERSISTENT

Use g: '\\ntbaksrv\common'
Use i: '\\ntbaksrv\prod'
Use k: '\\ntbaksrv\service'
Use m: '\\ntserver\sdpcmrpw'
Use o: '\\royal\mis'
Use y: '\\terminal\share_point'

; use Z: /home ; Don't use this. Map it via the User Manager or AD tools
; Windows 9x Can Not map the Z: drive as the redirector uses this
; drive during the logon process

;printers.kix:
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim $priReg, $x, $i, $rc, $ps
$loc='HKEY_CURRENT_USER\Network\LPT1'
$reg='HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion'
$dev=$reg+'\Devices'
$nprt=Split(ReadValue($reg+'\Windows','Device'),',')[0]
$sysdrv=SubStr('%WINDIR%',1,2)

If Exist('H:')
$ps='H:\Scripts_DO_NOT_DELETE'
Else
$ps=$sysdrv+'\Scripts'
EndIf
If 0=Exist($ps)
MD $ps
EndIf
$ps=$ps+'\Printsetup.ini'

$i=0
Do
If '\\'=Left($x,2)
$priReg=$priReg+$x
EndIf
$x=EnumValue($dev,$i)
$i=$i+1
Until @error

If Len($priReg)
$rc=WriteProfileString($ps,'Printers','','')
$priReg=Split($priReg,'\\')
For $i=1 to Ubound($priReg)
$rc=WriteProfileString($ps,'Printers',$i,'\\'+$priReg[$i])
Next
EndIf

Select
Case InStr($nprt,'\\') ;WRITE THE DEFAULT PRINTER TO THE CONFIG
$rc=WriteProfileString($ps,'Printers','Default',$nprt)
Use LPT1: /delete /persistent
Use LPT1: $nprt /persistent
Case $nprt='' AND Exist($ps) ;NO DEFAULT PRINTER, LOAD PRINTERS FROM SAVED INFO
For Each $key In Split(ReadProfileString($ps,'Printers',''),Chr(10))
$nul=AddPrinterConnection(ReadProfileString($ps,'Printers',$key))
Next
$nprt=ReadProfileString($ps,'Printers','Default')
$rc=SetDefaultPrinter($nprt)
Use LPT1: $nprt /persistent
Case NOT InStr($nprt,'\\') ;LOCAL PRINTER DEFAULT, SO WE WANT TO REMOVE NETWORK MAPPING
Use LPT1: /delete /persistent
EndSelect

Function LocalAdmin()
$LocalAdmin=InGroup('@wksta\'+SIDToName('S-1-5-32-544'))-1+@inwin
EndFunction

Function IdentifyRemoteUser($strComputer)
Break On
Dim $strComputer
$objWMIService = GetObject("winmgmts:" + "{impersonationLevel=impersonate}!\\" + $strComputer + "\root\cimv2")
$colComputer = $objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
For Each $objComputer In $colComputer
? $objComputer.UserName
Next
EndFunction




Shell '%COMSPEC% /C \\Ntbaksrv\NETLOGON\use.exe'


_________________________
Ekadanta Mahakaya Surya koti samaprabha Nirbighnam kurume deva sarbakaryeshu sarbada

Top
#43346 - 2003-07-25 11:27 PM Re: Help with printer script - revised
rbardo Offline
Fresh Scripter

Registered: 2003-07-24
Posts: 47
Loc: USA
I may not need the sid for the keys i want to edit presently,(above) but for others that need a username specified as part of the subkey name, I think I will.. [Wink]
_________________________
Ekadanta Mahakaya Surya koti samaprabha Nirbighnam kurume deva sarbakaryeshu sarbada

Top
#43347 - 2003-07-25 11:37 PM Re: Help with printer script - revised
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
There are syntax errors in the code, e.g. in UpdateRegistry. The GetSID won't work as you hardcoded the username. Filenames that contain spaces need ot be enclosed in double qoutes, e.g. the first sHELL statement. The last function does nto have an endfunction.

If tyhe whole thing is a login script then it doesn't make sense. Why print all usernames? What's NET.EXE doing?

the whole script needs a serious cleanup.

[ 26. July 2003, 02:27: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#43348 - 2003-07-25 11:54 PM Re: Help with printer script - revised
rbardo Offline
Fresh Scripter

Registered: 2003-07-24
Posts: 47
Loc: USA
ok, its toast... [Frown]
_________________________
Ekadanta Mahakaya Surya koti samaprabha Nirbighnam kurume deva sarbakaryeshu sarbada

Top
#43349 - 2003-07-26 02:32 AM Re: Help with printer script - revised
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
It's not toast. However, it does have problems. The best way is to start with a script outline, then add functionality piece-by piece. Get each piece working, then add the next one.

Also, keep clean syntax and structure. Don't mix script code, subroutines, and functions. Functiosn should grouped togeter either at the very top or very bottom of a script. However, the preferred method is to have functions inside a function library, e.g. FUNCTIONS.UDF that gets included into the scirp by placing a CALL FUNCTIONS.UDF at the top of the script.

It's also good to use SETOPTION('Explicit','on') as this will catch syntax errors in variables and ensures correct scoping of variables.

It takes more time to debug sloppy code than coding in a clean and concise way fromt he very beginning.

Finally, if you copy functions from the UDF Forum, please keep the UDF Header intact.

[ 26. July 2003, 02:48: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#43350 - 2003-07-26 02:37 AM Re: Help with printer script - revised
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11601
Loc: CA
Does that mean I have to go back and put my UDF headers back in? [Eek!] [Wink]
Top
#43351 - 2003-07-26 03:05 AM Re: Help with printer script - revised
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Hmmm... the hard-coded user name works for me. [Big Grin]

My GetSID UDF requires a special DLL to be registered. It is fine for admin scripts but if it's logon scripting you are after, there are other similar UFDs that simply mine the SID out of the local registry.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#43352 - 2003-07-26 04:02 PM Re: Help with printer script - revised
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
There's Name2SID(), for example.
_________________________
There are two types of vessels, submarines and targets.

Top
#43353 - 2003-07-26 06:03 PM Re: Help with printer script - revised
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
adam (hope that is your name [Smile] ),

One thing I noticed immediately when I saw your REG extracts is the word adam. Any registry merges/changes should not be that specific. You will probably want to have a look at the following:
Copy a shortcut to the Desktop, Start Menu, etc.

We have pretty fine list of FAQ too at:
KiXtart FAQ & How to's

Also, with your changes to -
(1) "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"

Looks just like a policy. [Smile]

(2) "HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Outlook\Security"
Is OL 2002 or XP all you have in the work place? Did you get a chance to look at -
Outlook/Exchange Configuration

This has great deal of research put into configuring and setting up Outlook.

HTH,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#43354 - 2003-07-27 03:07 AM Re: Help with printer script - revised
rbardo Offline
Fresh Scripter

Registered: 2003-07-24
Posts: 47
Loc: USA
Thanks guys..

Here is the latest that for the most part works except I cant find that .ini file for the printers anywhere.. Yes it does create the folder..

code:
 ;===============================================================================================
;**** Created with KiXscripts Editor | http://KiXscripts.com ****
;**** Last Modified on 7/26/2003 at 5:00:40 PM by rbardo ****
;===============================================================================================


;If @INWIN=1 ; Excludes all Windows 9x systems
;If LocalAdmin ; Only runs if the user has Local workstation admin rights
; Most installers and uninstallers will not run if the user
; does not have Admin rights
$CheckWS=ReadValue('HKLM\Software\VendingData Corporation\WS', 'RANUNINSTALLER')
If $CheckWS <> 1
If Exist('%ProgramFiles%\OfficeView Pro\uninstWS.exe')
Shell '%COMSPEC% /C %ProgramFiles%\OfficeView Pro\uninstWS.exe /S /y'
$MarkWS=WriteValue('HKLM\Software\VendingData Corporation\WS', 'RANUNINSTALLER', '1', 'REG_SZ')
; Mark the registry so that this program does not run every time the user logs in
EndIf
EndIf
;EndIf
;EndIf

; http://www.a-navigator.com/an/index.html
Use W: /DELETE /PERSISTENT
Use W: '\\holdem\asset_db$'
Shell '%COMSPEC% /C W:\ina32.exe'
Use W: /DELETE /PERSISTENT


; The rest of the script will run for all systems including Windows 9x


Use g: '\\ntbaksrv\common'
Use i: '\\ntbaksrv\prod'
Use k: '\\ntbaksrv\service'
Use m: '\\ntserver\sdpcmrpw'
Use o: '\\royal\mis'
Use y: '\\terminal\share_point'

Copy '\\terminal\desktop\*.*' 'c:\documents and settings\' + @USERID + '\desktop' /s

; use Z: /home ; Don't use this. Map it via the User Manager or AD tools
; Windows 9x Can Not map the Z: drive as the redirector uses this
; drive during the logon process
;***********************************************************************
;**
;** InstallRegFiles($Regfiles)
;**
Function InstallRegFiles($Regdir)
$RegFiles=$RegDir + "\*.reg"
If Exist($Regdir)
$RegFile=Dir($Regfiles)
While $RegFile<>"" AND @Error=0
;Install RegFile
If $NT_mode="yes" ; If this is NT than don't install regfiles that start with "w9_"
If Left($RegFile,3) <> "w9_"
stpDbgMessage("Info"," - Installing : " + $Regdir + "\" + $RegFile)
If RunShell($windir + "/regedit /s " + $Regdir + "\" + $RegFile)<>0
stpDbgMessage("Error","@ERROR - Regedit : " + $Regdir + "\" + $RegFile,@SERROR)
EndIf
EndIf
Else ; If this is W9x than don't install regfiles that start with "nt_"
If Left($RegFile,3) <> "nt_"
stpDbgMessage("Info"," - Installing : " + $Regdir + "\" + $RegFile)
If RunShell($windir + "/regedit /s " + $Regdir + "\" + $RegFile)<>0
stpDbgMessage("Error","@ERROR - Regedit : " + $Regdir + "\" + $RegFile,@SERROR)
EndIf
EndIf
EndIf
$RegFile=Dir()
If @Error<>0 AND @Error<>18
stpDbgMessage("Error","@ERROR - Retrieving Files for Dir : " +$Regdir ,@SERROR)
EndIf
Loop
EndIf
EndFunction

; Default My Documents to Z: drive
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WriteValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'Personal', 'Z:\\', 'Reg_SZ')
WriteValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'My Pictures', 'Z:\\My Pictures', 'Reg_SZ')

;printers.kix
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$loc='HKEY_CURRENT_USER\Network\LPT1'
$reg='HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion'
$dev=$reg+'\Devices'
$nprt=Split(ReadValue($reg+'\Windows','Device'),',')[0]
$sysdrv=SubStr('%WINDIR%',1,2)
Dim $priReg, $x, $i, $rc, $ps

If Exist('Z:')
$ps='Z:\Scripts_DO_NOT_DELETE'
Else
$ps=$sysdrv+'\Scripts'
EndIf
If 0=Exist($ps)
MD $ps
EndIf
$ps=$ps+'\Printsetup.ini'

$i=0
Do
If '\\'=Left($x,2)
$priReg=$priReg+$x
EndIf
$x=EnumValue($dev,$i)
$i=$i+1
Until @error

If Len($priReg)
$rc=WriteProfileString($ps,'Printers','','')
$priReg=Split($priReg,'\\')
For $i=1 to Ubound($priReg)
$rc=WriteProfileString($ps,'Printers',$i,'\\'+$priReg[$i])
Next
EndIf

Select
Case InStr($nprt,'\\') ;WRITE THE DEFAULT PRINTER TO THE CONFIG
$rc=WriteProfileString($ps,'Printers','Default',$nprt)
Use LPT1: /delete /persistent
Use LPT1: $nprt /persistent
Case $nprt='' AND Exist($ps) ;NO DEFAULT PRINTER, LOAD PRINTERS FROM SAVED INFO
For Each $key In Split(ReadProfileString($ps,'Printers',''),Chr(10))
$nul=AddPrinterConnection(ReadProfileString($ps,'Printers',$key))
Next
$nprt=ReadProfileString($ps,'Printers','Default')
$rc=SetDefaultPrinter($nprt)
Use LPT1: $nprt /persistent
Case NOT InStr($nprt,'\\') ;LOCAL PRINTER DEFAULT, SO WE WANT TO REMOVE NETWORK MAPPING
Use LPT1: /delete /persistent
EndSelect

Shell '%COMSPEC% /C \\Ntbaksrv\NETLOGON\use.exe'

PLease let me know what you guys think..
Thanks.

[ 27. July 2003, 09:18: Message edited by: rbardo ]
_________________________
Ekadanta Mahakaya Surya koti samaprabha Nirbighnam kurume deva sarbakaryeshu sarbada

Top
#43355 - 2003-07-27 09:58 AM Re: Help with printer script - revised
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Robert,

Two comments:

(1) What are you merging with regedit /s ? You can do these changes all with KiXtart.
(2) The use of Z: Drive will give you trouble with Windows 9x clients as they tend to use that drive for logging in.

If you are merging this.. It is setup based on profile anyway and it should not matter..

"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"

However, you can use the Shell Folders for your script..

For this, you should be able to change to KiXtart -


$reg='HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer'
IF READVALUE($REG,'NoDriveTypeAutoRun')<>'00000095'
 $RC=WRITEVALUE($REG,'NoDriveTypeAutoRun','00000095','REG_BINARY')
ENDIF
IF READVALUE($REG,'NoDrives')<>'0000001f'
 $RC=WRITEVALUE($REG,'NoDrives','0000001f','REG_BINARY')
ENDIF



And also with -


$REG='HKCU\Software\Microsoft\Office\10.0\Outlook\Security'
IF READVALUE($REG,'Level')<>'3'
 $RC=WRITEVALUE($REG,'Level','','REG_DWORD')
ENDIF
IF READVALUE($REG,'UseCRLChasing')<>'1'
 $RC=WRITEVALUE($REG,'UseCRLChasing','1','REG_DWORD')
ENDIF
IF READVALUE($REG,'Level1Remove')<>'txt;gif;html;htm'
 $RC=WRITEVALUE($REG,'Level1Remove','txt;gif;html;htm','REG_SZ')
ENDIF



I am still wrestling around with the "adam" thing. You should just simply use the folders that are generated with the user's profile. 'Nuff said.

I took your code and made some simple modifications to it. I also added comments for you to look at as well.



 ;===============================================================================================
 ;**** Created with KiXscripts Editor | http://KiXscripts.com ****
 ;**** Last Modified on 7/26/2003 at 5:00:40 PM by rbardo ****
 ;===============================================================================================
 $usershel='HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders'

 ;If @INWIN=1 ; Excludes all Windows 9x systems
 ;If LocalAdmin  ; Only runs if the user has Local workstation admin rights
 ; Most installers and uninstallers will not run if the user
 ; does not have Admin rights
 IF ReadValue('HKLM\Software\VendingData Corporation\WS','RANUNINSTALLER')<>1
    ;%ProgramFiles% may not exist under 9x
    IF Exist('%ProgramFiles%\OfficeView Pro\uninstWS.exe';IF You need a specific version, use GETFILEVERSION
       SHELL '%COMSPEC% /C %ProgramFiles%\OfficeView Pro\uninstWS.exe /S /y'
       $markws=WriteValue('HKLM\Software\VendingData Corporation\WS','RANUNINSTALLER','1','REG_SZ')
       ; Mark the registry so that this program does not run every time the user logs in
    ENDIF
 ENDIF
 ;EndIf
 ;EndIf
             
 http://www.a-navigator.com/an/index.html
 USE W: /delete /persistent
 USE W: '\\holdem\asset_db'+'$$'
 ;Can't the next line be done with a RUN instead of a shell?
 SHELL '%COMSPEC% /C W:\ina32.exe'
 USE W: /delete /persistent

 ; The rest of the script will run for all systems including Windows 9x
 USE g: '\\ntbaksrv\common'
 USE i: '\\ntbaksrv\prod'
 USE k: '\\ntbaksrv\service'
 USE m: '\\ntserver\sdpcmrpw'
 USE o: '\\royal\mis'
 USE y: '\\terminal\share_point'

 IF @INWIN=1
    $desktop=readvalue($usershel,'desktop')
 ELSE
    $desktop='%WINDIR%\DESKTOP'
 ENDIF
 COPY '\\terminal\desktop\*.*' $desktop /s

 ; use Z: /home ; Don't use this.  Map it via the User Manager or AD tools
 ; Windows 9x Can Not map the Z: drive as the redirector uses this
 ; drive during the logon process
 ;***********************************************************************
 ;**
 ;**  InstallRegFiles($Regfiles)
 ;**
 FUNCTION InstallRegFiles($regdir)
    $regfiles=$regdir + "\*.reg"
    IF Exist($regdir)
       $regfile=Dir($regfiles)
       WHILE $regfile<>"" AND @error=0
          ;Install RegFile
          IF $nt_mode="yes"  ; If this is NT than don't install regfiles that start with "w9_"
             IF Left($regfile,3) <"w9_"
                stpDbgMessage("Info","    - Installing : " + $regdir + "\" + $regfile)
                IF RunShell($windir + "/regedit /s " + $regdir + "\" + $regfile)<>0
                   stpDbgMessage("Error","@ERROR - Regedit : " + $regdir + "\" + $regfile,@serror)
                ENDIF
             ENDIF
          ELSE   
             ; If this is W9x than don't install regfiles that start with "nt_"
             IF Left($regfile,3) <"nt_"
                stpDbgMessage("Info","    - Installing : " + $regdir + "\" + $regfile)
                IF RunShell($windir + "/regedit /s " + $regdir + "\" + $regfile)<>0
                   stpDbgMessage("Error","@ERROR - Regedit : " + $regdir + "\" + $regfile,@serror)
                ENDIF
             ENDIF
          ENDIF
          $regfile=Dir()
          IF @error<>0 AND @error<>18
             stpDbgMessage("Error","@ERROR - Retrieving Files for Dir : " +$regdir ,@serror)
          ENDIF
       LOOP
    ENDIF
 ENDFUNCTION

 IF @inwin=1 ;EXCLUE 9X machines from this
    ;Windows 9x machines may also have trouble with the Z: drive as it is used for logins< /font>
    ;Windows 9x cannot use ADDPRINTERCONNECTION,SETDEFAULTPRINTER,etc.
    ; Default My Documents to Z: drive
    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ;Two comments here -
    ;(1) doubling the \\ will double the write back to the registry
    ;(2) if you want to quiet the write, assign a dummy var to it
    IF READVALUE($usershel,'Personal')<>'Z:\'
       $rc=WriteValue($usershel,'Personal','Z:\','Reg_SZ')
    ENDIF
    IF READVALUD($usershel,'My Pictures')<>'Z:\My Pictures'
       $rc=WriteValue($usershel,'My Pictures','Z:\My Pictures','Reg_SZ')
    ENDIF


    ;printers.kix
    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    DIM $prireg$x$i$rc$ps
    $loc='HKEY_CURRENT_USER\Network\LPT1'
    $reg='HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion'
    $dev=$reg+'\Devices'
    $nprt=Split(ReadValue($reg+'\Windows','Device'),',')[0]
    $sysdrv=SubStr('%WINDIR%',1,2)

    IF Exist('Z:')
       $ps='Z:\Scripts_DO_NOT_DELETE'
    ELSE
       $ps=$sysdrv+'\Scripts'
    ENDIF
    IF 0=Exist($ps)
       MD $ps
    ENDIF
    $ps=$ps+'\Printsetup.ini'

    $i=0
    DO
       IF '\\'=Left($x,2)
          $prireg=$prireg+$x
       ENDIF
       $x=EnumValue($dev,$i)
       $i=$i+1
    UNTIL @error

    IF Len($prireg)
       $rc=WriteProfileString($ps,'Printers','','')
       $prireg=Split($prireg,'\\')
       FOR $i=1 TO Ubound($prireg)
          $rc=WriteProfileString($ps,'Printers',$i,'\\'+$prireg[$i])
       NEXT
    ENDIF

    SELECT
    CASE 
       InStr($nprt,'\\';WRITE THE DEFAULT PRINTER TO THE CONFIG
       $rc=WriteProfileString($ps,'Printers','Default',$nprt)
       USE LPT1: /delete /persistent
       USE LPT1: $nprt /persistent
    CASE 
       $nprt='' AND Exist($ps;NO DEFAULT PRINTER, LOAD PRINTERS FROM SAVED INFO
       FOR EACH $key IN Split(ReadProfileString($ps,'Printers',''),Chr(10))
          $nul=AddPrinterConnection(ReadProfileString($ps,'Printers',$key))
       NEXT
       $nprt=ReadProfileString($ps,'Printers','Default')
       $rc=SetDefaultPrinter($nprt)
       USE LPT1: $nprt /persistent
    CASE 
       NOT InStr($nprt,'\\';LOCAL PRINTER DEFAULT, SO WE WANT TO REMOVE NETWORK MAPPING
       USE LPT1: /delete /persistent
    ENDSELECT
 ENDIF


 FUNCTION LocalAdmin()
    $localadmin=InGroup('@wksta\'+SIDToName('S-1-5-32-544'))-1+@inwin
 ENDFUNCTION

 FUNCTION IdentifyRemoteUser($strcomputer)
    BREAK ON
    DIM $strcomputer
    $objwmiservice = GetObject("winmgmts:" + "{impersonationLevel=impersonate}!\\" + $strcomputer + "\root\cimv2")
    $colcomputer = $objwmiservice.execquery ("Select * from Win32_ComputerSystem")
    FOR EACH $objcomputer IN $colcomputer
       ? $objcomputer.username
    NEXT
 ENDFUNCTION

 ;WHAT IS THIS NEXT LINE USED FOR?
 SHELL '%COMSPEC% /C \\Ntbaksrv\NETLOGON\use.exe'



HTH,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 131 anonymous users online.
Newest Members
dimi575, Drecksnacken, Nlill, webtools321, multiman
17734 Registered Users

Generated in 0.046 seconds in which 0.013 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org