#186377 - 2008-03-19 05:26 PM
File Copying Script assistance
|
DieselDoc
Fresh Scripter
Registered: 2008-03-19
Posts: 13
|
Hey all, I'm a new sysadmin for a company where I guess someone was a big KiXtart fan in the past. I was going to rewrite the default logon script in vbscript but I'm actually intrigued by KiX and am actively bringing myself up to speed.
I attempted to add some code to the existing script which runs Kix2001, trying to copy a remote desktop connection icon from a network share to the desktops of users in only one particular AD group. Nothing happens though haha. Here's what I did:
; **Adding icon to group below's Desktop**
IF INGROUP ("APP-Allscripts")
IF EXIST (%UserProfile% + "\Desktop\Allscripts.rdp") =0
COPY "\\Sec01\deploy$\Shortcuts\Allscripts.rdp" %UserProfile% + "\Desktop"
ENDIF
The first set of code in the section is the following:
;******************************************************************
;*** BEGIN Instructions by Group
;******************************************************************
:SOFTWARE
;IF INGROUP("APP-COUMACARE")
; USE G: "\\DC02\COUMACARE"
; COLOR w+/n
; AT (4,6) "CoumaCare Mapped"
;ENDIF
IF INGROUP("APP-QUICKTIME")
USE Q: "\\APP01\QUICKTIME"
COLOR w+/n
AT (4,6) "QUICKBOOKS Mapped"
ENDIF
The script is continuing to run normally I think otherwise. I think I may have gotten a message about 'ERROR : LABEL [APP-Allscripts] not found!' but not any more.
Any thoughts appreciated. Thanks!
Edited by DieselDoc (2008-03-19 05:51 PM)
|
|
Top
|
|
|
|
#186382 - 2008-03-19 05:58 PM
Re: File Copying Script assistance
[Re: DieselDoc]
|
Witto
MM club member
   
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
I presume when you say "AD group", you mean Organisational Unit, Don't you? InGroup() works with security groups, not with Organisational Units. I presume InContainer() can help you.
|
|
Top
|
|
|
|
#186385 - 2008-03-19 06:26 PM
Re: File Copying Script assistance
[Re: Witto]
|
DieselDoc
Fresh Scripter
Registered: 2008-03-19
Posts: 13
|
Nope, APP-Allscripts is an actual group in AD. Thanks though, I can definitely see using InContainer in the future.
I didn't know if my syntax was off or something, or placement in the kix file?
|
|
Top
|
|
|
|
#186392 - 2008-03-19 09:28 PM
Re: File Copying Script assistance
[Re: Mart]
|
DieselDoc
Fresh Scripter
Registered: 2008-03-19
Posts: 13
|
Ok, I made the EndIf correction, thanks! I removed the $ from deploy$ and still nothing. But I did notice a couple things.
There are two sets of drive mapping code. The first uses the following layout:
:~MedicalRecords
USE T: "\\POK-OAFS-1\Transcription"
COLOR w+/n
AT (9,6) "Transcription Mapped"
Goto ALL
The second:
IF INGROUP("ADGROUP_NAME")
USE R: "\\SERVER_NAME\SHARE"
COLOR w+/n
AT (8,6) "SHARE NAME Mapped"
ENDIF
Both sets seem to be working...but with a little nuance. The first set I think is pulling the 'group' info from Description field in AD and not looking for a particular AD group membership for the user. The second set feeds off that but does look at the AD groups to determine whether it should add additional drives. I don't know if that makes any sense.
I noticed this bit at the top of the kix file. Don't know if it will shed any light on the issue:
$OS="@dos" ;OS Version
$public="\\THC-PA\Public" ;Public Share
$service="@comment" ;Department assigned from comment field
$Pserver="\\THC-PA\" ;Server for User Accounts
$department="$Pserver" + "$service" ;Departmental Share
Edited by DieselDoc (2008-03-19 09:40 PM)
|
|
Top
|
|
|
|
#186395 - 2008-03-19 11:32 PM
Re: File Copying Script assistance
[Re: Mart]
|
DieselDoc
Fresh Scripter
Registered: 2008-03-19
Posts: 13
|
Yeah that's what I had been thinking but I went into AD Users and Computers, double-clicked my 'testuser' and changed the info in the Description field and it changed which drives were mapped according to mapping groups from the 1st set of code. Weird huh?
Even though some users may be in more than one AD group listed in the 2nd set of code (ie. a user, like me that is in Billing, MedRecs, and IT AD Groups) they are only having drives mapped for ONE department. The department listed in their Description field in their AD user profile settings. I only get IT drives even though I should be able recieve mapped drives from the 2nd set of map drive coding lines that includes IF INGROUP("~IT"),IF INGROUP("~MedicalRecords"), and IF INGROUP("~Accounting"), etc.
I'm in all of those AD Groups but I don't get the mapped drives UNLESS I change my Description in my AD user profile to another department. And then I only get that one departments drives.
Oh and it's still ignoring my file copying code haha. I wonder what would happen if I was to put 'APP-Allscripts' as my Description in AD. I'll try that as a test tomorrow.
Might need to start from scratch, sounds like this script may have been botched from the get go.
Thanks for the assistance!
BTW - no prob with the hidden share I had created a normal one. Thanks for the good lookin out though!
|
|
Top
|
|
|
|
#186396 - 2008-03-19 11:33 PM
Re: File Copying Script assistance
[Re: DieselDoc]
|
DieselDoc
Fresh Scripter
Registered: 2008-03-19
Posts: 13
|
Should I post more of my kix file coding?
Edited by DieselDoc (2008-03-19 11:33 PM)
|
|
Top
|
|
|
|
#186404 - 2008-03-20 02:41 PM
Re: File Copying Script assistance
[Re: Mart]
|
DieselDoc
Fresh Scripter
Registered: 2008-03-19
Posts: 13
|
Hope this isn't TMI. Code is below as requested. Again, I just want to do a simple drive mapping per AD group(s), and file copy per AD group. I've been reading the tutorials, so I'm sure I'll figure it out eventually but I'm pressed for time just with this icon copy project, that's all. Thanks again for your time.
; TEST.KIX
;Set Variables
CLS
$OS="@dos" ;OS Version
$public="\\THC-GA\Public" ;Public Share
$service="@comment" ;Department assigned from comment field
$Pserver="\\THC-GA\" ;Server for User Accounts
$department="$Pserver" + "$service" ;Departmental Share
;$personal="$Pserver" + "@userid$$" ;Personal Share
;BIG
;COLOR r+/n
;AT (2,4) "SEASONS"
;COLOR r+/n
;AT (10,4) "GREETINGS"
;SLEEP 5
CLS
Small
Color b+/n
Box (0,0,17,60,GRID) ;'background grid'
Color b/n
Box (2,4,15,58,Å) ;'shadow' of the box
Color g+/n
Box (2,3,14,57,FULL)
Color c+/n
At (4,6) "Greetings, @fullname!"
At (5,6) "Today is "@day" "@month" "@mdayno
SetTime "\\thc-ga\" ;SET the TIME
Color c+/n
At (7,6) "Time Synchronized : "
Color y+/n
At (7,32) @time + " on " + @date
Sleep 3 ;Wait for 10 secs (or key)
FlushKB
;SMALL
;COLOR b+/n
;BOX (0,0,17,60,GRID) ;'background grid'
;COLOR b/n
;BOX (2,4,15,58,Å) ;'shadow' of the box
;COLOR g+/n
;BOX (2,3,14,57,FULL)
;COLOR c+/n
;AT (4,6) "NOTICE: "
;AT (5,6) ""
;AT (7,6) ""
;AT (8,6) ""
;AT (9,6) ""
;SLEEP 10
;FLUSHKB
Small
Color b+/n
Box (0,0,17,60,GRID) ;'background grid'
Color b/n
Box (2,4,15,58,Å) ;'shadow' of the box
Color g+/n
Box (2,3,14,57,FULL)
;******************************************************************
;*** BEGIN Diplays User locale information
;******************************************************************
Color w+/n
At (4,6) "Userid : " ;display some text strings
At (5,6) "Full name : "
At (6,6) "Department : "
At (7,6) "Workstation : "
At (8,6) "Domain : "
At (9,6) "Logon Server : "
Color y+/n
At (4,21) @userid ;...and some macro's
At (5,21) @fullname
At (6,21) @comment
At (7,21) @wksta
At (8,21) @domain
At (9,21) @LSERVER
Sleep 2 ;Wait for 3 secs (or key)
FlushKB
;******************************************************************
;*** END Diplays User locale information
;******************************************************************
;******************************************************************
;*** BEGIN Diplays User locale information
;******************************************************************
Color b+/n
Box (0,0,17,60,GRID) ;'background grid'
Color b/n
Box (2,4,15,58,Å) ;'shadow' of the box
Color g+/n
Box (2,3,14,57,FULL)
;USE M: "$mail" ;MAP Mail Share
;COLOR w+/n
;AT (5,6) "Mail Share Mapped : "
;COLOR y+/n
;AT (5,32) "$mail"
;******************************************************************
;*** END Diplays User locale information
;******************************************************************
;******************************************************************
;*** BEGIN Instructions by Department
;******************************************************************
Use N: "$public" ;MAP Public Share
Color w+/n
At (6,6) "Public Share Mapped : "
Color y+/n
At (6,32) "$public"
Use O: "$department" ;MAP Department Share
Color w+/n
At (7,6) "Department Share Mapped : "
Color y+/n
At (7,32) "$department"
;USE P: "$personal" ;MAP Personal Share
;COLOR w+/n
;AT (8,6) "Personal Share Mapped : "
;COLOR y+/n
;AT (8,32) "$personal"
Goto $service ;Map additional shares for each DEPT
Goto ALL
;:~TEMPLATE OBJECT ;Template Object
;USE Q: "\\MERCURY\Working"
;COLOR w+/n
;AT (9,6) "Engineering WORKING Mapped"
;USE R: "\\MERCURY\Vault"
;COLOR w+/n
;AT (10,6) "Engineering VAULT Mapped"
;USE S: "\\MERCURY\DCN"
;COLOR w+/n
;AT (11,6) "Engineering DCN Mapped"
;USE T: "\\MERCURY\Plot"
;COLOR w+/n
;AT (12,6) "Engineering PLOT Mapped"
Goto ALL
:~Administration ;Administration
Goto ALL
:~AHPs
Use T: "\\Cs-cb\Transcription"
Color w+/n
At (9,6) "Transcription Mapped"
Goto ALL
:~Billing
Goto ALL
:~Clinical
Use T: "\\Cs-cb\Transcription"
Color w+/n
At (9,6) "Transcription Mapped"
Goto ALL
:~Diagnostics
Use T: "\\Cs-cb\Transcription"
Color w+/n
At (9,6) "Transcription Mapped"
Goto ALL
:~IT
;USE T: "\\Cs-cb.hvca-gc.com\Transcription"
;COLOR w+/n
;AT (9,6) "Transcription Mapped"
;GOTO ALL
Use S: "\\THC-GA\Software"
Color w+/n
At (10,6) "Software Mapped"
Goto ALL
:~MedicalRecords
;USE T: "\\POK-OAFS-1\Transcription"
;COLOR w+/n
;AT (9,6) "Transcription Mapped"
Goto ALL
Use U: "\\cbs-cb\Transcription"
Color w+/n
At (9,6) "Transcription Mapped"
Goto ALL
:~Accounting
Goto ALL
:~Physicians ;Physicians
Use * /DELETE
Use T: "\\Cbs-cb\Transcription"
Color w+/n
At (9,6) "Transcription Mapped"
Goto ALL
:~Scheduling
Goto ALL
;******************************************************************
;*** END Instructions by Department
;******************************************************************
:ALL
Sleep 3 ;Wait for 3 secs (or key)
CLS
FlushKB
;******************************************************************
;*** BEGIN General Registry Changes
;******************************************************************
;:HOMEPAGE
;$ReturnCode = WRITEVALUE("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main","Start
Page","http://slashdot.org/","REG_SZ")
;IF $Return code = 0
;? "Key Loaded...."
;ENDIF
:REGISTERED-OWNER
$ReturnCode = WriteValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion","RegisteredOrganization","Napa
Valley Cardiovascular Associates, P.C.","REG_SZ")
If $Return code = 0
"Key Loaded...."
EndIf
$ReturnCode = WriteValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion","RegisteredOwner","The Health
Center","REG_SZ")
If $Return code = 0
"Key Loaded...."
EndIf
;:LANDESK
;IF EXIST ("C:\PROGRAM FILES\INTEL\LDCM\BIN\IIDS.EXE")
; $ReturnCode = WRITEVALUE("HKEY_LOCAL_MACHINE\SOFTWARE\INTEL\LANDesk\Client Manager\CurrentVersion","Remote Admin
Computer Address",3232235789,"REG_DWORD")
; IF $Return code = 0
; ? "Key Loaded...."
; ENDIF
; $ReturnCode = WRITEVALUE("HKEY_LOCAL_MACHINE\SOFTWARE\INTEL\LANDesk\Client Manager\CurrentVersion","Remote Admin
Computer Name","","REG_SZ")
; IF $Return code = 0
; ? "Key Loaded...."
; ENDIF
; $ReturnCode = WRITEVALUE("HKEY_LOCAL_MACHINE\SOFTWARE\INTEL\LANDesk\Client Manager\CurrentVersion","Remote Admin
Computer Port","6780","REG_SZ")
; IF $Return code = 0
; ? "Key Loaded...."
; ENDIF
;ENDIF
;******************************************************************
;*** END General Registry Changes
;******************************************************************
Small
Color b+/n
Box (0,0,17,60,GRID) ;'background grid'
Color b/n
Box (2,4,15,58,Å) ;'shadow' of the box
Color g+/n
Box (2,3,14,57,FULL)
;******************************************************************
;*** BEGIN Instructions by Group
;******************************************************************
:SOFTWARE
;IF INGROUP("APP-COUMCARE")
; USE G: "\\THC-GA\COUMCARE"
; COLOR w+/n
; AT (4,6) "CoumaCare Mapped"
;ENDIF
If InGroup("APP-PEACHTREE")
Use Q: "\\APP01\PEACHTREE"
Color w+/n
At (4,6) "PEACHTREE Mapped"
EndIf
If InGroup("APP-SOLOMAN")
Use S: "\\SUPERIOR-FS\SOLOMAN"
Color w+/n
At (5,6) "SOLOMAN Mapped"
EndIf
If InGroup("APP-APD")
Use R: "\\DENARI\EZTIMEG"
Color w+/n
At (6,6) "EZTIME Mapped"
Use T: "\\DENARI\TIMEOUT"
Color w+/n
At (7,6) "TIMEOUT Mapped"
EndIf
If InGroup("APP_HOLSTER")
Use U: "\\THC-GA\HOLSTER DAT
Color w+/n
At (4,6) "TRANSCRIPTION Mapped"
EndIf
; **Adding icon to group below's Desktop**
If InGroup("APP-Allscripts")
If Not Exist (%UserProfile% + "\Desktop\Allscripts.rdp")
Copy "\\Sec01\deploy\Shortcuts\Allscripts.rdp" %UserProfile% + "\Desktop"
EndIf
EndIf
;IF INGROUP("GROUP_NAME")
;USE R: "\\SERVER_NAME\SHARE"
;COLOR w+/n
;AT (8,6) "SHARE NAME Mapped"
;ENDIF
;******************************************************************
;*** END Instructions by Group
;******************************************************************
;******************************************************************
;*** BEGIN Miscellaneous Instructions
;******************************************************************
; **Clears the C:\TEMP Directory** [BEGIN]
:CLEAR
Go C:
Del "C:\TEMP\*.PDF"
Del "C:\TEMP\*.DWG"
Del "C:\TEMP\*.DOC"
Del "C:\TEMP\*.BMP"
Del "C:\TEMP\*.JPG"
Del "C:\TEMP\*.TXT"
Del "C:\TEMP\*.XLS"
Del "C:\TEMP\*.PPT"
Del "C:\TEMP\*.MDB"
Del "C:\TEMP\*.ZIP"
Del "C:\TEMP\*.EXE"
; **Clears the C:\TEMP Directory** [END]
; ** Distribute updated "Hosts" file to clients [Begin] **
;$FileName='hosts'
;$SrcPath='\\server\share'
;if $OStype='NT'
; $DestPath='$DllDir\drivers\etc'
;else ; OS=9x
; $DestPath='%windir%'
;else ; OS=XP
; $DestPath='%SystemRoot%\system32\drivers\etc'
;endif
;$DestFile=$DestPath+'\'+$FileName
;$SrcFile=$SrcPath+'\'+$FileName
;if comparefiletimes($DestFile,$SrcFile)<0 or 1-exist($DestFile)
; copy $SrcFile $DestPath
;endif
; ** Distribute updated "Hosts" file to clients [End] **
;IF EXIST ("C:\FLAG.TXT")
; GOTO SOFTWARE
; ELSE
; GO C:
; CD C:\
; MD TEMP
; COPY "N:\TEMPLATES\*.DOT" "C:\WINDOWS\APPLICATION DATA\MICROSOFT\TEMPLATES\*.*"
; COPY "N:\TEMPLATES\*.TXT" "C:\*.*"
;ENDIF
;******************************************************************
;*** END Miscellaneous Instructions
;******************************************************************
:END
CLS
Exit
Edited by DieselDoc (2008-03-20 03:03 PM)
|
|
Top
|
|
|
|
#186408 - 2008-03-20 06:31 PM
Re: File Copying Script assistance
[Re: DieselDoc]
|
Gargoyle
MM club member
   
Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
|
I have taken the liberty of cleaning it up a little bit for you. One of my personal peaves is the annoying information that Admins send out to the users who really don't care.
So to that point I have removed all of your Screen output, and have removed all of the "GOTO" statements. I did add a debugging output where you are having your particular issue.
; TEST.KIX
If NOT @LOGONMODE
Break On
EndIf
$SO=SETOPTION("Explicit", "ON")
$SO=SETOPTION("NoMacrosInStrings", "ON")
$SO=SETOPTION("NoVarsInStrings", "ON")
$SO=SETOPTION("WrapAtEOL", "ON")
;Set Variables
CLS
$OS="@dos" ;OS Version
$public="\\THC-GA\Public" ;Public Share
$service="@comment" ;Department assigned from comment field
$Pserver="\\THC-GA\" ;Server for User Accounts
$department="$Pserver" + "$service" ;Departmental Share
;$personal="$Pserver" + "@userid$$" ;Personal Share
;SetTime "\\thc-ga\" ;Unless you have NT / 95 not needed
;******************************************************************
;*** BEGIN Instructions by Department
;******************************************************************
Use * /DELETE /Persistant
Use N: $public ;MAP Public Share
Use O: $department ;MAP Department Share
Select
Case $service = "~AHPs"
Use T: "\\Cs-cb\Transcription"
Case $service = "~Clinical"
Use T: "\\Cs-cb\Transcription"
Case $service = "~Diagnostics"
Use T: "\\Cs-cb\Transcription"
Case $service ="~IT
Use S: "\\THC-GA\Software"
Case $service = "~MedicalRecords"
Use U: "\\cbs-cb\Transcription"
Case $service = "~Physicians"
Use T: "\\Cbs-cb\Transcription"
EndSelect
:REGISTERED-OWNER
$ReturnCode = WriteValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion","RegisteredOrganization","Napa Valley Cardiovascular Associates, P.C.","REG_SZ")
$ReturnCode = WriteValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion","RegisteredOwner","The Health Center","REG_SZ")
;******************************************************************
;*** BEGIN Instructions by Group
;******************************************************************
:SOFTWARE
If InGroup("APP-PEACHTREE")
Use Q: "\\APP01\PEACHTREE"
EndIf
If InGroup("APP-SOLOMAN")
Use S: "\\SUPERIOR-FS\SOLOMAN"
EndIf
If InGroup("APP-APD")
Use R: "\\DENARI\EZTIMEG"
Use T: "\\DENARI\TIMEOUT"
EndIf
If InGroup("APP_HOLSTER")
Use U: "\\THC-GA\HOLSTER DAT"
EndIf
; **Adding icon to group below's Desktop**
If InGroup("APP-Allscripts")
If Not Exist (%UserProfile% + "\Desktop\Allscripts.rdp")
Copy "\\Sec01\deploy\Shortcuts\Allscripts.rdp" %UserProfile% + "\Desktop"
? "Return code was :" + @Error + " -Descriptive text " + @serror ;remove after testing
EndIf
EndIf
;******************************************************************
;*** END Instructions by Group
;******************************************************************
;******************************************************************
;*** BEGIN Miscellaneous Instructions
;******************************************************************
; **Clears the C:\TEMP Directory** [BEGIN]
Go C:
Del "C:\TEMP\*.PDF"
Del "C:\TEMP\*.DWG"
Del "C:\TEMP\*.DOC"
Del "C:\TEMP\*.BMP"
Del "C:\TEMP\*.JPG"
Del "C:\TEMP\*.TXT"
Del "C:\TEMP\*.XLS"
Del "C:\TEMP\*.PPT"
Del "C:\TEMP\*.MDB"
Del "C:\TEMP\*.ZIP"
Del "C:\TEMP\*.EXE"
;******************************************************************
;*** END Miscellaneous Instructions
;******************************************************************
Exit
_________________________
Today is the tomorrow you worried about yesterday.
|
|
Top
|
|
|
|
#186418 - 2008-03-21 02:19 PM
Re: File Copying Script assistance
[Re: Gargoyle]
|
DieselDoc
Fresh Scripter
Registered: 2008-03-19
Posts: 13
|
Awesome - I can actually make heads and tails of what your script is doing. I'll give it a go.
Edited by DieselDoc (2008-03-21 02:57 PM)
|
|
Top
|
|
|
|
#186421 - 2008-03-21 02:57 PM
Re: File Copying Script assistance
[Re: DieselDoc]
|
DieselDoc
Fresh Scripter
Registered: 2008-03-19
Posts: 13
|
Ok...I could SWEAR it worked perfectly once! But now I'm getting:
ERROR : undefined variable [$OS]! Line : 14
Line 14 is the following, of course - $OS="@dos"
If I comment out Line 7 ;$SO=SetOption("Explicit", "ON") it gets further but errors out on Line : 27 - Use N: $public
ERROR : error in USE statement! Line : 27
I tested by creating a logontest.bat file which points to file kixtest.kix file. I run once I've already logged in to the desktop in Windows. Should that make a difference on the outcome? My original logon.bat seems to run aok from the desktop. Or maybe I need to update my kix32.exe file to the latest? I'm running 4.22, I believe. Thx.
|
|
Top
|
|
|
|
#186450 - 2008-03-24 06:10 PM
Re: File Copying Script assistance
[Re: Gargoyle]
|
DieselDoc
Fresh Scripter
Registered: 2008-03-19
Posts: 13
|
Yes, thanks for that...I've been reading up and now I see that you turned the 'Explicit' option to 'On', forcing the declaring of variables.
For some reason, though, it still doesn't like the USE command usage in Line 57 and...looks like Line 58 also.
Use * /DELETE /Persistant ;Line 56
Use N: $public ;MAP Public Share
Use O: $department ;MAP Department Share
Getting the following:
ERROR : error in USE statement! testkix.kix Line : 57
Funny thing is that I'm getting that error even if I replace the line:
Use N: $public ;MAP Public Share
With:
Use N: "\\THC-GA\Public" ;MAP Public Share
I know that one little character in the wrong place and it won't work but I'm just not seeing what I need to change.
Any thoughts?
Edited by DieselDoc (2008-03-24 08:11 PM)
|
|
Top
|
|
|
|
#186452 - 2008-03-24 08:38 PM
Re: File Copying Script assistance
[Re: Glenn Barnas]
|
DieselDoc
Fresh Scripter
Registered: 2008-03-19
Posts: 13
|
Yeah, no dice...still getting:
ERROR : error in USE statement! testkix.kix Line : 57
Not sure I get your question. The only USE syntax I'm familiar with thus far is:
USE [""] "" [/USER:] [/PASSWORD:] [/PERSISTENT]
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 519 anonymous users online.
|
|
|