#198116 - 2010-03-21 10:15 PM
checking my script
|
BReed
Fresh Scripter
Registered: 2010-03-17
Posts: 10
Loc: nc
|
Hey everyone, I was hoping I could get some advice on my script. I've got about 30+ bits and pieces I've been testing and working on to make everything work the way I'd like it to (and work together in prod environment), but there's some things I'm still having trouble with. One thing that doesn't seem to work is the Select Case statement in testkix.kix, and I am just not seeing why
Our environment consist of about 1000 pcs that run natively and 1000 thin clients connecting to a Citrix Desktop environment. Our Citrix servers are running Server 2003 x64 for terminal sessions and most of our workstations are XP SP3 (although we do have some 32bit and 64bit Win 7 machines). I've got multiple print servers currently, but just for testing really because all of this rewrite began with printers not getting mapped correctly. There's a 2003 32bit and a 2008 64bit print server that can be used.
The first kix script is:
"WestCare Logon Script"
Dim $cn, $x
;-----------------------------------------
;logging
;-----------------------------------------
If Open(3, "\\wcfs1\apps\Log\log.log", 5) = 0
$x = WriteLine(3, "Logged In:," + @MDayNo + "/" + @Month + "/" + @Year + " " + @TIME + "," + @UserID + "," + @PRIV + "," + @WkSta + "," + @IPADDRESS0 + "," + @ADDRESS + "," + @LSERVER + @CRLF)
Else
Beep
? "failed to open file, error code : [" + @ERROR + "]"
EndIf
;-----------------------------------------
;end logging
;-----------------------------------------
;Detecting 64 bit OS
;-----------------------------------------
"64-bit!" @ONWOW64
If @ONWOW64 = 1
SetOption('Wow64FileRedirection', 'ON')
EndIf
;-----------------------------------------
;Variable Settings
;-----------------------------------------
;You must explicitly declare all variables using Dim, Global or ReDim statements
;-----------------------------------------
SetOption(Explicit, "ON")
;-----------------------------------------
;ASP Group kills script
;-----------------------------------------
If InGroup("ASP")
Exit
EndIf
;-----------------------------------------
;Fix Radiology Reports
;-----------------------------------------
If InGroup("DL_Fix_RadReports")
Shell "FixRadReports.bat"
EndIf
;-----------------------------------------
;ECS Print mapping
;-----------------------------------------
If InGroup("appecs2000")
Shell 'xcopy /y \\wcfs1\apps\tohome\CA\*.* "H:\CA\"'
If AddPrinterConnection("\\ecs2000control\hpacct-hp8100-01") = 0
AddPrinterConnection("\\ecs2000control\hpacct-hp8100-01")
;SetDefaultPrinter ("\\ecs2000control\hpacct-hp8100-01")
EndIf
Shell 'xcopy /y \\wcfs1\apps\tohome\windows\claimsad.ini "H:\Windows\"'
EndIf
;-----------------------------------------
;Print to Disk Selection
;-----------------------------------------
If InGroup("print-print-to-disk1")
If AddPrinterConnection("\\wcps1\print-to-disk1") = 0
AddPrinterConnection("\\wcps1\print-to-disk1") EndIf
EndIf
;-----------------------------------------
;Checking for Lotus Notes files
;-----------------------------------------
If Exist("h:\windows\notes.ctx") = 1
If Exist("h:\windows\notes.ini") = 0
Move "H:\windows\notes.ctx" "H:\windows\notes.ini"
Shell "xcopy /y p:\tohome\windows\ihadactxfile2.txt H:\windows\"
EndIf
EndIf
;-----------------------------------------
;OS Select
;-----------------------------------------
Select
Case @PRODUCTTYPE = "Windows XP Professional" Or "Windows XP Professional Tablet PC" Or "Windows 7 Enterprise Edition"
;declaring Computer Name variable
;
$cn = "@WKSTA"
;-----------------------------------------
;Mapping Drives
;-----------------------------------------
Call mapdrives.kix
;-----------------------------------------
;ending script for PACS workstations
;-----------------------------------------
If (SubStr($cn, 1, 4)) = "nwks"
Exit
EndIf
;-----------------------------------------
;ending script for PowerScribe workstation
;-----------------------------------------
If (SubStr($cn, 1, 10)) = "pwrscribe"
Exit
EndIf
;-----------------------------------------
;Running Remote Scan logon script for HPF DCS Workstations
;-----------------------------------------
If InGroup("appHPFDCS")
If Exist("H:\Windows\twain.dll") = 0
Shell "rslogon.bat"
EndIf
Shell "HPF_DCS.bat"
EndIf
;-----------------------------------------
;Running PC Print script
;-----------------------------------------
Call printpc.kix
;-----------------------------------------
;END PC KIX
;-----------------------------------------
Case @PRODUCTTYPE = "Windows Server 2003" Or "Windows Server 2003 R2" Or "Windows Server 2008 (R2)"
;-----------------------------------------
;Mapping Drives
;-----------------------------------------
Call mapdrives.kix
;-----------------------------------------
;Running Citrix Printer Script
;-----------------------------------------
Call printcitrix.kix
;-----------------------------------------
;Calling Citrix Kix Script
;-----------------------------------------
Call citrix.kix
;-----------------------------------------
EndSelect
The map drives kix script is pretty basic and seems to work well in all environments, but just for the sake of completion, I'll post part of it
;unmap all drive
Use * /delete /persistent
;---------------------------------------
;mapping all user drives
Use H: %homeshare%
Use P: \\wcfs1\apps
Use S: \\wcfs1\root\share
;---------------------------------------
;mapping group drives
If InGroup("DL_app_pwhc_workfilemap")
Use I: \\homecare-db\mckesson\pwhc\workfile\prod1
EndIf
;---------------------------------------
If InGroup("DL_Folder_Birth_Cert")
Use T: "\\wcfs1\backup$\Birth Certificate"
EndIf
;---------------------------------------
If InGroup("DL_App_Kronos")
Use K: "\\kronserv\kronos1$"
Use L: "\\kronserv\kronos2$"
EndIf
;---------------------------------------
Here's the print mapping kix script. If you look into the testkix.kix, you'll see that there are two printer kix scripts: printpc.kix and printcitrix.kix The only difference in them is about half way down there's a variable @WRKSTA and for citrix it has been changed to %clientname%
I'm sure there's a right way to combine them into a single script nicely, but I'm just not skilled enough to make it happen. I'd also like to remove the redundency in the print script and have the first part that maps from the ini to add printers to the $sDone variable being used in the script provided by Richard H.
;------------------------------------
;Mapping Printers
;------------------------------------
? @FULLNAME + ": Please wait while your printers are being added...."
;------------------------------------
;Setting Variables
;------------------------------------
Dim $sDOMAIN, $sSpooler, $sDone, $iDefaultDone, $ID, $PrinterList, $DefPrinter, $Printer, $iIndex,
$sGroup, $Index, $sPrinter, $c, $bk, $conn, $counter
$sDOMAIN = "westcare"
$sSpooler = "\\wcps1\"
$sDone = @CRLF
$iDefaultDone = 0
$c = 0
$bk = "HKEY_CURRENT_USER\Printers\Connections"
$conn = EnumKey($bk, $counter)
While @error = 0
$c = $c + 1
$conn = DelKey($bk + "\" + $conn)
$conn = EnumKey($bk, $counter)
Loop
$ID = Left(@WKSTA, 4)
$PrinterList = Split(ReadProfileString('\\wcdc02\netlogon\printers.ini', $ID, 'Printers'), ';')
$DefPrinter = ReadProfileString('\\wcdc02\netlogon\printers.ini', $ID, 'Default')
For Each $Printer in $PrinterList
AddPrinterConnection($Printer)
Next
SetDefaultPrinter($DefPrinter)
;set index to 0 for looping through groups
$iIndex = 0
;get first group name
$sGroup = EnumGroup($Index)
While Len($sGroup) And @ERROR = 0
;if group name starts with print- or printd-
If (InStr($sGroup, $sDOMAIN + "\print-") = 1) Or ( InStr($sGroup, $sDOMAIN + "\printd-") = 1 )
$sPrinter = SubStr($sGroup, InStr($sGroup, "-") + 1) ; Note, this won't work if you have "-" in the domain name
If InStr($sDone, @CRLF + $sPrinter + @CRLF)
; Printer has already been added - no point in doing it again.
Else
; Add printer and make sure it’s successful
If AddPrinterConnection($sSpooler + $sPrinter)
; Display error message and text
"Error Adding Printer: " + $sPrinter + @CRLF
"Error: " + @SERROR + @CRLF
Else
"Added printer: " + $sPrinter + @CRLF ; Display success message
$sDone = $sDone + $sPrinter + @CRLF ; Record success
EndIf
EndIf
; If printer has been added OK AND is default AND a default has not been set already...
If InStr($sGroup, $sDOMAIN + "\printd-") = 1
If SetDefaultPrinter($sSpooler + $sPrinter)
; Display error message and text
"Error Setting Default Printer: " + $sPrinter + @CRLF
"Error: " + @SERROR + @CRLF
Else
"Set default to: " + $sPrinter + @CRLF ; Display success message.
EndIf
EndIf
EndIf
$iIndex = $iIndex + 1 ;increase the loop counter by 1
$sGroup = EnumGroup($iIndex) ;get next group name
; loop until end of groups list
Loop
Here is the citrix.kix. It seems to work well when tested, but like I mentioned in the top, the Select Case statement isn't calling this script like it's supposed to when the OS is Server 2003
;****************Version 1.0************
;*****REMEMBER TO UPDATE VERSION AT
;*****BOTTOM OF :RUNONCE
;*****
;*****
;*****
;*****
;***************************************
$VER = ReadValue("HKEY_CURRENT_USER\Software\LogonApp", "Version")
If $VER = 1.0
Goto ALWAYS
Else
Goto RUNONCE
EndIf
;---------------------------------------
:RUNONCE
;---------------------------------------
;
;---------------------------------------
;Old Lotus shortcuts
;---------------------------------------
If Exist("H:\Windows\Start Menu\Programs\Lotus applications") = 1
Del "H:\Windows\Start Menu\Programs\Lotus applications\*.*"
Shell 'rmdir "H:\Windows\Start Menu\Programs\Lotus applications"'
EndIf
If Exist("h:\windows\Start Menu\Lotus Notes.lnk") = 1
Del "h:\windows\Start Menu\Lotus Notes.lnk"
EndIf
If Exist("h:\windows\Start Menu\Lotus Notes R5.pnagent") = 1
Del "h:\windows\Start Menu\Lotus Notes R5.pnagent"
EndIf
If Exist("h:\windows\Desktop\Lotus Notes.lnk") = 1
Del "h:\windows\Desktop\Lotus Notes.lnk"
EndIf
If Exist("h:\windows\Desktop\Lotus Notes R5.pnagent") = 1
Del "h:\windows\Desktop\Lotus Notes R5.pnagent"
EndIf
;---------------------------------------
;Kronos Application shortcuts
;---------------------------------------
If Exist("h:\windows\Start Menu\Timekeeper Central Software.lnk") = 1
Del "h:\windows\Start Menu\Timekeeper Central Software.lnk"
EndIf
If Exist("h:\windows\Desktop\Timekeeper Central Software.lnk") = 1
Del "h:\windows\Desktop\Timekeeper Central Software.lnk"
EndIf
If Exist("%userprofile%\Start Menu\Programs\Kronos Applications\HBOC Upload.lnk") = 1
Del "%userprofile%\Start Menu\Programs\Kronos Applications\HBOC Upload.lnk"
EndIf
If Exist("%userprofile%\Start Menu\Programs\Kronos Applications\Timekeeper Central Software.lnk") = 1
Del "%userprofile%\Start Menu\Programs\Kronos Applications\Timekeeper Central Software.lnk"
EndIf
;---------------------------------------
;HBOC shortcuts
;---------------------------------------
If Exist("h:\windows\Start Menu\HBOC.lnk") = 1
Del "h:\windows\Start Menu\HBOC.lnk"
EndIf
If Exist("h:\windows\Desktop\HBOC.lnk") = 1
Del "h:\windows\Desktop\HBOC.lnk"
EndIf
;---------------------------------------
;Microsoft Office Shortcuts
;---------------------------------------
If InGroup("DL_App_Microsoft_PowerPoint_2003_Remote")
If Exist("H:\Windows\Start Menu\Programs\MS Office\Microsoft Office PowerPoint 2003.lnk") = 0
Shell 'xcopy /y "P:\StartMen\Programs\MS Office\Microsoft Office PowerPoint 2003.lnk" "H:\Windows\Start Menu\Programs\MS Office\"'
EndIf
EndIf
If InGroup("DL_App_Microsoft_Word_2003_Remote")
If Exist("H:\Windows\Start Menu\Programs\MS Office\Microsoft Office Word 2003.lnk") = 0
Shell 'xcopy /y "P:\StartMen\Programs\MS Office\Microsoft Office Word 2003.lnk" "H:\Windows\Start Menu\Programs\MS Office\"'
EndIf
If Exist("h:\personal\wordrecovery") = 0
MD "h:\personal\wordrecovery"
EndIf
EndIf
If InGroup("DL_App_Microsoft_Excel_2003_Remote")
If Exist("H:\Windows\Start Menu\Programs\MS Office\Microsoft Office Excel 2003.lnk") = 0
Shell 'xcopy /y "P:\StartMen\Programs\MS Office\Microsoft Office Excel 2003.lnk" "H:\Windows\Start Menu\Programs\MS Office\"'
EndIf
EndIf
;****************************************************************************
;****************************************************************************
; Write the version info into the registry. Edit version number if necessary
;****************************************************************************
;****************************************************************************
AddKey("HKEY_CURRENT_USER\Software\LogonApp")
WriteValue("HKEY_CURRENT_USER\Software\LogonApp", "Version", "1.0", "REG_SZ")
;****************************************************************************
;****************************************************************************
;---------------------------------------
:ALWAYS
;---------------------------------------
;
;---------------------------------------
;Shortcut Organizer
;---------------------------------------
If Exist("h:\windows\shortcutorg.ini") = 1
Shell "\\wcfs1\apps\ShortcutOrganizer2003\ShortcutOrganizer.exe /s"
EndIf
;---------------------------------------
;Horizon Patient Folder
;---------------------------------------
If Exist("h:\windows\Start Menu\HPF Workstation.lnk") = 1
Del "h:\windows\Start Menu\HPF Workstation.lnk"
EndIf
If Exist("h:\windows\Desktop\HPF Workstation.lnk") = 1
Del "h:\windows\Desktop\HPF Workstation.lnk"
EndIf
If InGroup("DL_App_HPF_QCI")
Shell "HPF_QCI.bat"
EndIf
If InGroup("DL_App_HPF_Workstation")
If Exist("H:\Windows\IMNET.INI") = 0
Shell 'xcopy /y "P:\Tohome\Windows\IMNET.INI" "H:\Windows\"'
Shell 'xcopy /y "P:\Tohome\Windows\IMNETWFE.INI" "H:\Windows\"'
Shell 'xcopy /y "P:\Tohome\Windows\EPRS.INI" "H:\Windows\"'
Shell 'xcopy /y "P:\Tohome\Windows\win.ini" "H:\Windows\"'
EndIf
If Exist("H:\Windows\Start Menu\Programs\Horizon Patient Folder\HPF Web Portal.url") = 0
Shell 'xcopy /y "P:\StartMen\Programs\Horizon Patient Folder\HPF Web Portal.url" "H:\Windows\Start Menu\Programs\Horizon Patient Folder\"'
EndIf
EndIf
;---------------------------------------
;Lotus Notes
;---------------------------------------
If InGroup("DL_App_Lotus_R7")
If Exist("h:\notes\data\R7.txt") = 0
Del "H:\Notes\Data\*.ntf"
Del "H:\Notes\Data\cache.dsk"
Del "H:\Notes\Data\perweb.nsf"
Shell 'xcopy /y "\\wcfs1\Apps\Lotus\R7Templates" "H:\Notes\Data\"'
EndIf
If Exist("H:\windows\Start Menu\Programs\Lotus Notes\Lotus Notes 7.lnk") = 0
Shell 'xcopy /y "P:\startmen\programs\Lotus Notes\Lotus Notes 7.lnk" "H:\Windows\Start Menu\Programs\Lotus Notes\"'
Shell 'xcopy /y "P:\startmen\programs\Lotus Notes\Lotus Notes 7.lnk" "H:\Windows\Start Menu\"'
Shell 'xcopy /y "P:\startmen\programs\Lotus Notes\Lotus Notes 7.lnk" "H:\Windows\Desktop\"'
EndIf
If Exist("h:\windows\notes.ini") = 0
If Exist("h:\windows\notes.ctx") = 0
Shell "xcopy /y p:\tohome\windows\notes.ini H:\windows\"
EndIf
EndIf
If Exist("h:\windows\notes.ctx") = 1
If Exist("h:\windows\notes.ini") = 0
Move "H:\windows\notes.ctx" "H:\windows\notes.ini"
Shell "xcopy /y p:\tohome\windows\ihadactxfile3.txt H:\windows\"
EndIf
EndIf
EndIf
;---------------------------------------
;Catena
;---------------------------------------
If InGroup("G_Dept_H_ED")
If Exist("H:\Windows\Desktop\Catena - ED.pnagent") = 0
Shell 'xcopy /y "P:\StartMen\Programs\Catena\Catena - ED.pnagent" "H:\Windows\Desktop\"'
EndIf
EndIf
That's not quite all of it, but enough to see what I'm doing.
I realize GOTO functions are possibly frowned upon here, but it seemed like the easiest way to do the reg version thing I've attempted.
Again, I'm all about getting expert opinions because frankly I'm just not up to par. I did order the KixStart book to help me along, so eventually I'll get this, but nothing tops the experience of seasoned vets.
Thanks everyone and thanks again to those who helped guide me in the right direction with my other post about print mapping
**and apologies the 8000 lines of comments and semi-colons. It's nice and pretty in ASE and helps me keep things clearer when working on it
|
|
Top
|
|
|
|
#198122 - 2010-03-22 01:27 PM
Re: checking my script
[Re: Arend_]
|
BReed
Fresh Scripter
Registered: 2010-03-17
Posts: 10
Loc: nc
|
ahhhhhhh, I see. I thought it would work the way I had it, but it certainly makes sense and I should have tried it like that to begin with.
Thanks Richard, you're a life saver, and thank you apronk for the effort and input.
|
|
Top
|
|
|
|
#198124 - 2010-03-22 01:50 PM
Re: checking my script
[Re: Arend_]
|
BradV
Seasoned Scripter
  
Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
|
This is definitely a nit-pick, but if I'm going to evaluate the same function more than once, I set it to a variable and then just reference the variable. For example:
$PType=@PRODUCTTYPE
Case $PType = "Windows XP Professional" Or $PType = "Windows XP Professional Tablet PC" Or $PType = "Windows 7 Enterprise Edition"
If you compiler is efficient, it should store $PType in a register and then just reference this register when it needs the value rather than re-evaluating the macro each time. I picked up this habit years ago when I was doing machine language programming. 
Regards,
Brad
|
|
Top
|
|
|
|
#198125 - 2010-03-22 01:59 PM
Re: checking my script
[Re: BradV]
|
BradV
Seasoned Scripter
  
Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
|
Another suggestion I would make is to move your links to an ini file. You can have separate sections for Lotus, Kronos, etc. Under each, put link1=... for each of the links. Then, in your script, just loop through each section testing and deleting the links. You could do two loops. The outer loop would loop through the section headers, and the inner loop would hit each link. That way you remove the data from your script. If you need to add a section, delete a link, etc, you just need to modify your ini file and not your script.
Regards,
Brad
|
|
Top
|
|
|
|
#198136 - 2010-03-23 01:22 PM
Re: checking my script
[Re: BradV]
|
BReed
Fresh Scripter
Registered: 2010-03-17
Posts: 10
Loc: nc
|
Hey I just want to thank everyone again for their help. Turned this loose into production yesterday and everything has been smooth
|
|
Top
|
|
|
|
#198150 - 2010-03-24 04:33 AM
Re: checking my script
[Re: BReed]
|
cjutting
Fresh Scripter
Registered: 2010-02-05
Posts: 40
Loc: IA
|
Maybe I'm out of line.. Mod delete if it is..
Do I see another McKesson Paragon customer? I see a lot of the same goodies in here that I'm dealing with too
|
|
Top
|
|
|
|
#198181 - 2010-03-25 02:41 PM
Re: checking my script
[Re: cjutting]
|
BReed
Fresh Scripter
Registered: 2010-03-17
Posts: 10
Loc: nc
|
indeed cjutting! there's not too many of us out there and definitely not a lot using mckesson paragon in citrix like we do. feel free to drop me a line sometime at xxxx@xxxxx.org if you care to discuss paragon or whatnot. we often talk back and forth with other hospitals who use it because a lot of times it's us the end users who figure out the problems before mckesson
Edited by Richard H. (2010-03-25 03:43 PM) Edit Reason: Removed email address
|
|
Top
|
|
|
|
#198182 - 2010-03-25 03:49 PM
Re: checking my script
[Re: BReed]
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Brandon,
I've removed your mail address from your post for your own good 
The board supports "personal messaging" to allow members to communicate directly without exposing their email address, and you can of course use this to send someone your email address without making it visible to the rest of the world.
It's not against board rules or etiquette, and if you *really* want to expose your email address to spammers and virus engines then by all means edit it back into your post.
|
|
Top
|
|
|
|
#198187 - 2010-03-25 09:33 PM
Re: checking my script
[Re: cjutting]
|
BReed
Fresh Scripter
Registered: 2010-03-17
Posts: 10
Loc: nc
|
you're absolutely right Richard, thanks for fixing that for me. You would think I would know better...and I do, but apparently wasn't thinking straight
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 533 anonymous users online.
|
|
|