Showing posts with label Kixtart. Show all posts
Showing posts with label Kixtart. Show all posts

Tuesday, June 26, 2007

Kix Copy script with GUI (Kixtart UDF)

Another KIXtart UDF, well the title says it all...

Dependencies:
KiX 4.02 (or higher)
Shell32.dll version 4.71 or later. (Included with: Windows 2000, Windows NT 4.0 with Internet Explorer 4.0, Windows 98, Windows 95 with Internet Explorer 4.0.)

Usage:
GUICopy("source", "destination", "optional flag", "optional flag")
@ERROR " : " @SERROR ?

Optional Flags:
4 - Do not display a progress dialog box.
8 - Give the file being operated on a new name in a move, copy, or rename
operation if a file with the target name already exists.
16 - Respond with "Yes to All" for any dialog box that is displayed.
64 - Preserve undo information, if possible.
128 - Perform the operation on files only if a wildcard file name (*.*) is
specified.
256 - Display a progress dialog box but do not show the file names.
512 - Do not confirm the creation of a new directory if the operation requires
one to be created.
1024 - Do not display a user interface if an error occurs.
2048 - Version 4.71. Do not copy the security attributes of the file.
4096 - Only operate in the local directory. Don't operate recursively into
subdirectories.
8192 - Version 5.0. Do not copy connected files as a group. Only copy the
specified files.


Returns The exitcode of the command in the @ERROR macro.
@ERROR = 0 The operation completed successfully.
@ERROR = 2 The system cannot find the file specified. (Refers to Source file.)
@ERROR = 3 The system cannot find the path specified. (Bad destination path.)
@ERROR = 9 The storage control block address is invalid. (Most likely cancelled copy.)
@ERROR = 10 The environment is incorrect. (Incorrect Shell32.dll version.)
@ERROR = 87 The parameter is incorrect. (Use 0 or 1 to specify Copy or Move.)

Code Snippet:

  1. Function GUICopy($sSrc, $sDest, OPTIONAL $lFlags, OPTIONAL $bMove)
  2. Dim $sVer,$objShell,$objFldr
  3. If Not Exist($sSrc) Exit 2 Endif
  4. If Not Exist($sDest) Exit 3 Endif
  5. If @INWIN=1
  6. $sVer=GetFileVersion(%WINDIR%+"\System32\Shell32.dll","FileVersion")
  7. Else
  8. $sVer=GetFileVersion(%WINDIR%+"\System\Shell32.dll","FileVersion")
  9. Endif
  10. If $sVer<"4.71" Exit 10 Endif
  11. $objShell=CreateObject("Shell.Application")
  12. $objFldr=$objShell.NameSpace($sDest)
  13. If @ERROR<0 Exit VAL("&"+Right(DecToHex(@ERROR),4)) EndIf
  14. Select
  15. Case $bMove=1 $objFldr.MoveHere($sSrc,$lFlags)
  16. Case $bMove=0 $objFldr.CopyHere($sSrc,$lFlags)
  17. Case 1 Exit 87
  18. EndSelect
  19. If @ERROR<0 Exit VAL("&"+Right(DecToHex(@ERROR),4)) EndIf
  20. Exit @ERROR
  21. EndFunction

If at first you fail, call it version 1.0

Kix FTP (Kixtart UDF)

FTP via Kix? Yes!!!

Using Microsoft.XMLHTTP and ADODB.Stream.

Usage:

FTPget("ftp_address", "target_dest_drive", "id", "password")

Code Snippet:

  1. Function FTPget($sURL, $sTargetFile, optional $sUser, optional $sPass)
  2. Dim $oFTP, $oStream $sUser=""+$sUser
  3. $oFTP = CreateObject("Microsoft.XMLHTTP")
  4. if @error
  5. $ftpget=1
  6. exit 1
  7. endif
  8. $oStream = CreateObject("ADODB.Stream")
  9. if @error
  10. $ftpget=2
  11. exit 2
  12. endif
  13. if $sUser
  14. $oFTP.Open("GET", $sURL, not 1, $sUser, $sPass)
  15. else
  16. $oFTP.Open("GET", $sURL, not 1)
  17. endif
  18. if @error
  19. $ftpget=3
  20. exit 3
  21. endif
  22. $oFTP.Send
  23. $oStream.Type = 1
  24. $oStream.Mode = 3
  25. $oStream.open
  26. $oStream.Write($oFTP.responseBody)
  27. if @error
  28. $ftpget=4
  29. exit 4
  30. endif
  31. $oStream.SaveToFile($sTargetFile, 2)
  32. if @error
  33. $ftpget=5
  34. exit 5
  35. endif
  36. $oStream.Close
  37. EndFunction


If at first you fail, call it version 1.0

Monday, June 18, 2007

ADSI Kixtart UDF for Citrix login

Having a mixed mode environment gave us a lot of hassle when logging in to NT and querying group membership in AD... Specially in our case, we have nested OU's...

Ifmember.exe is useful for this problem but it does cause a slight delay in the login process and the users are complaining on the slow login session, some couldn't wait and cancels the connection... catastrophic experience ends up as a global complain... hmmm... some people are just impatient...

So to be able to execute an ADSI query through kix login script the function below can be inserted anywhere in the login script to perform InGroup query... or this can fully replace the built in InGroup function in kixtart.


Code Snippet:

  1. Function fnInGroupAD($sGroup,Optional $bComputer)
  2. Dim $objSys,$objTarget,$aMemberOf,$sMemberOf
  3. $objSys = CreateObject("ADSystemInfo")
  4. $objTarget = GetObject("LDAP://"+Iif($bComputer,$objSys.ComputerName,$objSys.UserName))
  5. $aMemberOf = $objTarget.GetEx("memberOf")
  6. For Each $sMemberOf in $aMemberOf
  7. If InStr($sMemberOf,"CN="+$sGroup+",")
  8. $fnInGroupAD = Not 0
  9. Exit
  10. EndIf
  11. Next
  12. $fnInGroupAD = NOT 1
  13. EndFunction

If at first you fail, call it version 1.0