Page 1 of 1 1
Topic Options
#183928 - 2007-12-19 11:21 AM Variable problem
lawe009 Offline
Fresh Scripter

Registered: 2004-04-14
Posts: 36
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 

Top
#183929 - 2007-12-19 11:58 AM Re: Variable problem [Re: lawe009]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
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 
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#183935 - 2007-12-19 12:55 PM Re: Variable problem [Re: Mart]
lawe009 Offline
Fresh Scripter

Registered: 2004-04-14
Posts: 36
Thanx Mart
That solved the problem.

Top
#183936 - 2007-12-19 01:01 PM Re: Variable problem [Re: lawe009]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Yeah. Sometimes environment vars (%stuff%) does not get translated to the actual value by kix. ExpandEnviromentVars solves that.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 507 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.05 seconds in which 0.021 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