Kixstart login script

Any Kixstart expert to explain what this script does:

Thanks

break on
$_=SetOption("WrapATEOL","ON")


;if readprofilestring("%userprofile%\"+@userid+".ini","General","FolderRedirect",)<>"1"
; Declare Dynamic Variable
$OldINI="\\szfileserv\joyce\DOPS Tools\Logs\SANMigration\OldPath.ini"   ; location of old INI.  Change this to reflect to be the same as updatehomedir
							 				;	FolderSync - 1:updated or is not needed
							 				;	FolderRedirect - 1:MyDoc moved and renamed
$newHD="\\szuserdata\userdata$"		 ; Share location of new Home dir
$robocopy="\\shopzilla.corp\NETLOGON\HQ\Scripts\robocopy.exe"	; Share location of robocopy - used to copy my dir
$csccmd1="\\shopzilla.corp\NETLOGON\HQ\Scripts\csccmd.exe"		; Share location of csccmd ver 1.1 - used to mod offline folder
$csccmd2="\\shopzilla.corp\NETLOGON\HQ\Scripts\csccmd2.exe"		; Share location of csccmd ver 1.0

; Flags and triggers
$reboot=0	; 0=No reboot, 1=reboot
$updateOF=0 ; Update Offline Folder Setting; 0=no 1=yes
$offlinemove=2 ; this doesn't do anything, i think
$offlinemovesuccess=2 ; Offline Folder Success:  0:no 1:yes 2:haven't started

if not exist ("%userprofile%\My Music")
	; Copy My Doc to new Home dir - copys into folder named after computer name
	$MyMusicFolder=ReadValue("HKU\"+@SID+"\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","My Music")
			
	select
		case instr($MyMusicFolder,@homeshr)
			?"Moving My Music folder from "+$MyMusicFolder+" to %userprofile%\My Music"
			md "%userprofile%\My Music"
			;$ObjectFSO=CreateObject("Scripting.FileSystemObject")
			;$FolderObject=$objectFSO.GetFolder($MyMusicFolder)
			shell 'cmd /c \\shopzilla.corp\NETLOGON\HQ\Scripts\robocopy "'+$MyMusicFolder+'" "%userprofile%\My Music" /move /e /w:0 /r:0'
			;$_=$FolderObject.move("%userprofile%\My Music")
			$_=WriteValue("HKU\"+@SID+"\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","My Music","%userprofile%\My Music","REG_SZ")
			$_=WriteValue("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell FOlders","My Music",CHR(37)+"USERPROFILE"+CHR(37)+'\My Music',"REG_EXPAND_SZ")
		case instr($MyMusicFolder,"%userprofile%\My Documents")
			;$ObjectFSO=CreateObject("Scripting.FileSystemObject")
			;$FolderObject=$objectFSO.GetFolder($MyMusicFolder)
			if not exist ("%userprofiile%\My Music")
				md "%userprofiile%\My Music"
			endif
			?"Moving My Music folder from "+$MyMusicFolder+" to %userprofile%\My Music"
			shell 'cmd /c \\shopzilla.corp\NETLOGON\HQ\Scripts\robocopy "'+$MyMusicFolder+'" "%userprofile%\My Music" /move /e /w:0 /r:0'
			;$_=$FolderObject.move("%userprofile%\My Music")
			$_=WriteValue("HKU\"+@SID+"\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","My Music","%userprofile%\My Music","REG_SZ")
			$_=WriteValue("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell FOlders","My Music",CHR(37)+"USERPROFILE"+CHR(37)+'\My Music',"REG_EXPAND_SZ")
		case $MyMusicFolder=""
			MD "%userprofile%\My Music"
			$_=WriteValue("HKU\"+@SID+"\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","My Music","%userprofile%\My Music","REG_SZ")
			$_=WriteValue("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell FOlders","My Music",CHR(37)+"USERPROFILE"+CHR(37)+'\My Music',"REG_EXPAND_SZ")
	endselect

	If (InSTR (ReadValue("HKU\"+@SID+"\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","My Video"),"%userprofile%\My Documents\My Video")) or (ReadValue("HKU\"+@SID+"\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","My Video")="")
		?"Moving My Video folder to %userprofile%\My Music"
		If Exist ("%userprofile%\My Documents\My Video")
			$ObjectFSO=CreateObject("Scripting.FileSystemObject")
			$FolderObject=$objectFSO.GetFolder("%userprofile%\My Documents\My Video")
			$_=$FolderObject.move("%userprofile%\My Video")
		Else
			MD "%userprofile%\My Video"
		EndIf
				
		$_=WriteValue("HKU\"+@SID+"\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","My Video","%userprofile%\My Video","REG_SZ")
		$_=WriteValue("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell FOlders","My Video",CHR(37)+"USERPROFILE"+CHR(37)+'\My Video',"REG_EXPAND_SZ")
	EndIf

else
	?"My Music already migrated."
endif

Open in new window

jskfanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steven HarrisPresidentCommented:
Copying/Moving files and writing values to the registry.
0
jskfanAuthor Commented:
I know but it is doing some testing (conditions)

what is it testing before copying ?

any details  ?
0
zalazarCommented:
Enable the possiblity to stop the Kixtart script
Enable wrapping console output
Define some variables
Check for directory "%userprofile%\My Music"
  If the directory exist give the message "My Music already migrated." and stop
  If the directory does not exist continue

[block]
If the "My Music" directory, which is defined in registry, points to the users home directory then move this directory (via the robocopy utility) to "%userprofile%\My Music"
Update the registry Shell Folders values for "My Music" with this new location "%userprofile%\My Music"

Or if the "My Music" directory, which is defined in registry, points to "%userprofile%\My Documents" then move this directory (via the standard windows API) to "%userprofile%\My Music"
Update the registry Shell Folders values for "My Music" with this new location "%userprofile%\My Music"

Or if the "My Music" directory is not defined in registry
Create directory "%userprofile%\My Music"
Update the registry Shell Folders values for "My Music" with this new location "%userprofile%\My Music"
[/block]

If the "My Video" directory, which is defined in registry, points to "%userprofile%\My Documents\My Video" or if the current "My Video" directory is not defined in the registry then
  Check if directory "%userprofile%\My Documents\My Video" exists
    If it exist then move directory "%userprofile%\My Documents\My Video" to "%userprofile%\My Video" (via the standard windows API)
    If it does not exist then create directory "%userprofile%\My Video"
  Update the registry Shell Folders values for "My Video" with the new location "%userprofile%\My Video"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

RobOwner (Aidellio)Commented:
In other words it's applying a file system policy your previous employee wanted to have.  As to why that is the case, only you will know.
0
zalazarCommented:
It might be that the policy is that it's not preferred to place Music files on home directories so they have to be moved to the local disk.
And that the default Music and Video directories should not be located below the "%userprofile%\My Documents" directory, maybe because there is an (automatic) backup of the My Documents folder in place.
0
jskfanAuthor Commented:
Excellent! Thank you
0
zalazarCommented:
You're welcome and thanks for the grade !
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.