lawe009
(Fresh Scripter)
2007-12-19 11:21 AM
Variable problem

Hi,
I´m having truble checking "My Documents" location. I´m gonna redirect it but I wanna check if it´s already redirected ie not default. Below is a script that doesn´t work if I type the $pers it will show %userprofie%\my documents but when checking the variale it will goto Endif. Whats wrong?
 Code:
If ingroup ("Citrix") 
 $Pers=Readvalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Personal")
  ? $Pers
  If $Pers= "%USERPROFILE%\My Documents"
   Writevalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "H:\", REG_EXPAND_SZ) 
   If Not exist "H:\Citrix My Documents"
    MD "H:\Citrix My Documents"
   Endif 
   SHELL '%COMSPEC% /e:1024 /c xcopy /s /c /r /y "%userprofile%\My Documents\*.*" "H:\Citrix My Documents" >nul'
  Endif
Endif 


Mart
(KiX Supporter)
2007-12-19 11:58 AM
Re: Variable problem

Alterd the scipt a bit. Does it work like this?

 Code:
If InGroup ("Citrix")
	$Pers = ExpandEnvironmentVars(ReadValue("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Personal"))
	If InStr ($Pers, "c:\documents and settings")
		WriteValue("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "H:\", REG_EXPAND_SZ) 
		If Not Exist "H:\Citrix My Documents"
			MD "H:\Citrix My Documents"
		EndIf
		Copy "%userprofile%\My Documents\" "H:\Citrix My Documents\"
	EndIf
EndIf 


lawe009
(Fresh Scripter)
2007-12-19 12:55 PM
Re: Variable problem

Thanx Mart
That solved the problem.


Mart
(KiX Supporter)
2007-12-19 01:01 PM
Re: Variable problem

Yeah. Sometimes environment vars (%stuff%) does not get translated to the actual value by kix. ExpandEnviromentVars solves that.