Jump to content
Sign in to follow this  
rbenner1184

Server URL Registry modification

Recommended Posts

rbenner1184

Hello,

I have been working with Citrix to make an install package and first let me just say it has been a pain. All my script is supposed to do is check the version of citrix and either uninstall it if it is older or point to the correct server if the version is current. In order to do this though I have to modify the registry. Now I have no idea why my script will not write to the registry. This is so frusterating, because I was waiting for ever for Citrix to even get the server up to test. Any extra eyes would be appreciated. Any thoughts? Thank you.

$SilentInstall = False
$installDir = "C:\Admin\AppUpd"
$logFile = $installDir & "\" & @ScriptName & ".log"
$logFileSubApp = $installDir & "\" & @ScriptName & "_bundled_app.log"
$logEntries = 0
$appTitle = "SMO Citrix Client version 13.3.0.55"
$ret = 0

;command options
;  <exe> /s
if $cmdLine[0] > 0 then
    for $a = 1 to $cmdLine[0]
        if StringLeft($cmdLine[$a],1) = "-" then
            $cmdLine[$a] = "/" & StringMid($cmdLine[$a],1)
        EndIf

        Switch $cmdLine[$a]
            Case "/s", "/q", "/silent", "/quiet"
                $SilentInstall = True

        EndSwitch
    Next
EndIf

;start the log
DirCreate($installDir)
_Log("Log Started.  SilentInstall = " & $SilentInstall)
;_CheckIfAdmin()  ;not needed on most installs since the #requireadmin immediately prompts to run as admin
if not $SilentInstall then ProgressOn($appTitle,"","Please Wait...",-1,-1,16)

ProgressSet(50,"Please wait...","Installing")
FileInstall("CitrixReceiverEnterprise.exe",$installDir & "\CitrixReceiverEnterprise.exe")
;FileInstall("CitrixClientRemoveAndReplace v1.3.vbs", $installDir & "CitrixClientRemoveAndReplace v1.3.vbs")

;install the Citrix Client if its not installed already


;its already installed, and will be uninstalled
$appVersion = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\CitrixOnlinePluginFull", "DisplayVersion")

If $appVersion  < "13.3.0.55" Then

ProgressSet(50,"Please wait...","Uninstalling")
_Log("Uninstalling Citrix Receiver Enterprise " & $appVersion)
RunWait("\\miappldms01\Packages\InTesting\SMOCitrixClient_POCT\ReceiverCleanupUtility.exe /s")
_Log("Install returned " & $ret & ", err=" & @error & ", ext=" & @extended)

ProgressSet(50,"Please wait...","Installing")
_Log("Installing Citrix Receiver Enterprise " & $appVersion)
RunWait('"' & $installDir & '\CitrixReceiverEnterprise.exe" /silent /includeSSON ADDLOCAL="ReceiverInside,ICA_Client,SSON,PN_Agent" ENABLE_SSON=yes SERVER_LOCATION="http://SMOCitrix.com/Citrix/PNAgent/Config.xml"',$installDir)
_Log("Install returned " & $ret & ", err=" & @error & ", ext=" & @extended)

ProgressSet(50,"Please wait...","Deleting files")
;Clean up the icons from the previous installs
FileDelete(@DesktopCommonDir & "\SMO Windows Client on Citrix.url")
FileDelete(@DesktopCommonDir & "\SMO Windows Client on Citrix.url.lnk")
FileDelete(@DesktopCommonDir & "\SMO Windows Client on Citrix.lnk")
run(@ComSpec & ' /c del /f /s /q "c:\SMO Windows Client on Citrix.lnk"',"c:\",@SW_HIDE)

ElseIf $appVersion = "13.3.0.55" Then

ProgressSet(50,"Writing to Registry")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE \Citrix\PNAgent","ServerURL", "REG_SZ", "http://SMOCitrix.com/Citrix/PNAgent/Config.xml")


ProgressSet(50,"Writing to Registry")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Citrix\PNAgent","ServerURL", "REG_SZ", "http://SMOCitrix.com/Citrix/PNAgent/Config.xml")


;kills and will restart process
ProcessClose("Receiver.exe")
Run("C:\Program Files\Citrix\ICA Client\Receiver\Receiver.exe")




EndIf


;set up the hosts file (DO NOT USE)
;~ FileInstall("hosts","C:\Windows\System32\drivers\etc\hosts",1)




;Configure the after install stuff like the icon and policy
;ProgressSet(80)
;_DoPostInstallOperations()



;prompt the user if not silent
ProgressOff()
if not $SilentInstall Then _ShowUserPrompt($ret)

;exit
_Log("Exiting")
exit $ret




;----------------------------------
; FUNCTIONS
;----------------------------------
Func _SendToCore($ReturnMessage)
    ;this will only work if its being sent through LANDesk
    If FileExists("C:\Program Files\LANDesk\LDClient\sdclient.exe") Then
        RunWait(@ComSpec & ' /c sdclient.exe /msg="' & $ReturnMessage & '."','C:\Program Files\LANDesk\LDClient',@SW_HIDE)
    EndIf
EndFunc

Func _Log($string)
    $datetime = @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & "." & @SEC & " - "

    if FileExists($logFile) AND $logEntries = 0 Then
        ;add a blank line if this is the first entry in the log
        RunWait(@ComSpec & " /c echo - >> " & $logFile,@WindowsDir,@SW_HIDE)
    EndIf

    ;add the pertinent log information
    RunWait(@ComSpec & " /c echo " & $datetime & $string & " >> " & $logFile,@WindowsDir,@SW_HIDE)

    ;increase the log entries
    $logEntries = $logEntries + 1
EndFunc

Func _CheckIfAdmin()
    if not IsAdmin() Then
        ;Log error (if there's write ability to the install dir then this will update)
        _Log("Admin rights were not detected.  Install will exit.")

        ;Display the error message if its not silent
        if not $SilentInstall Then
            MsgBox(16,"Error","You must have Administrator rights to run this.",300)
        EndIf

        exit 1625 ;This installation is forbidden by system policy. Contact your system administrator.
    EndIf
EndFunc

Func _ShowUserPrompt($returnCode)
    if $returnCode = 3010 then ;reboot needed
        $mret = MsgBox(64 + 4,$appTitle,"A reboot is required to complete this install." & @crlf & @crlf & "Would you like to reboot now?",300)
        if $mret = 6 Then  ;Yes was clicked
            Shutdown(6,$appTitle & " installation")
            exit $returnCode
        EndIf

    ElseIf $returnCode = 0 Then ;successful install
        MsgBox(64,$appTitle,"Installation completed successfully.",300)

    ElseIf $returnCode = 1 then ;already installed
        MsgBox(64,$appTitle,"This software is already installed." & @crlf & @crlf & "No action was taken.",300)

    Else
        MsgBox(16,$appTitle,"There was a problem running this install.  The return code was " & $returnCode & _
            @crlf & @crlf & "Refer to the following log(s) for more details:" & @crlf & "    " & $logFile & @crlf & "    " & $logFileSubApp,300)
    EndIf

EndFunc

Func _DoPostInstallOperations()
    ;install the icon and link
    _Log("Setting up the icon for All Users")
    FileInstall("Seagull.ico",@WindowsDir & "\System32\Seagull.ico",1)
    ;FileInstall("SMO Windows Client on Citrix.url",@DesktopCommonDir & "\SMO Windows Client on Citrix.url",1)
    FileDelete(@DesktopCommonDir & "\SMO Windows Client on Citrix.url")
    FileDelete(@DesktopCommonDir & "\SMO Windows Client on Citrix.url.lnk")
    FileCreateShortcut("http://smoctx/Citrix/XenApp/auth/login.aspx",@DesktopCommonDir & "\SMO Windows Client on Citrix","","","",@WindowsDir & "\System32\Seagull.ico")

    ;set up the policy to allow citrix to run
    $regKey = "HKLM\Software\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{9E22DED2-1858-4511-96C4-5625F54CECCA}"
    RegWrite($regKey,"AppPath","REG_SZ",@ProgramFilesDir & "\Citrix\ICA Client")
    RegWrite($regKey,"AppName","REG_SZ","wfcrun32.exe")
    RegWrite($regKey,"Policy","REG_DWORD",3)

    ;remove the run key entry
    RegDelete("HKLM\Software\Microsoft\Windows\CurrentVersion\Run","ConnectionCenter")

    ;remove the bho that slows down ie
    ;CtxIEInterceptorBHO - {2C4631FF-5CC8-4EBC-A0DF-34C92291759E}
    ;CtxVDAIEInterceptorBHO - {A44B166E-5097-4B07-8732-BFD924C3CF68}
    RegDelete("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects\{2C4631FF-5CC8-4EBC-A0DF-34C92291759E}")
    ;RegDelete("HKLM\SOFTWARE\Classes\CLSID\{2C4631FF-5CC8-4EBC-A0DF-34C92291759E}")
    ;RegDelete("HKLM\SOFTWARE\Classes\IEInterceptor.InterceptorBHO")
    ;RegDelete("HKLM\SOFTWARE\Classes\IEInterceptor.InterceptorBHO.1")


EndFunc
Edited by rbenner1184

Share this post


Link to post
Share on other sites
JLogan3o13

Exactly where is your script failing, and what error checking have you done? You say:

 

 Now I have no idea why my script will not write to the registry

 

but don't show any error checking to help yourself (or us) determine the point of failure. Help us help you :)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
rbenner1184

Thats just it there are no syntax erros that are shown. I run the Syntax Check Prod and this will tell me if i have errors. Mine seems to be a logic error. I am not sure why this will not execute the registry edit. THERE ARE NO ERRORS COMMING BACK. This is why I am confused why the changes are not beeing written.

Share this post


Link to post
Share on other sites
rbenner1184

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /prod /AU3Check /in "Y:\Ryan\SMOCitrixClient_POCT\SMOCitrixClient_POCTest_Corrections_Version2.au3"
+>15:00:54 Starting AutoIt3Wrapper v.2.1.2.9    Environment(Language:0409  Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X86)
>Running AU3Check (1.54.22.0)  from:C:\Program Files\AutoIt3
+>15:00:54 AU3Check ended.rc:0
>Exit code: 0    Time: 0.320

Thats what I get. No errors.

Share this post


Link to post
Share on other sites
JLogan3o13

Ok, but you STILL NEED TO DO ERROR CHECKING. You're writing out to your log file already, why not include an error checking statement after your RegWrites?

83.RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE \Citrix\PNAgent","ServerURL", "REG_SZ", "http://SMOCitrix.com/Citrix/PNAgent/Config.xml")

  If @error Then ;write error message to log file






√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
l3ill

Return Value
Success: Returns 1. 
Failure: Returns 0 if error writing registry key or value. 
 @error can be set to following values : 
 1 if unable to open requested key 
 2 if unable to open requested main key 
 3 if unable to remote connect to the registry 
 -1 if unable to open requested value 
 -2 if value type not supported

Share this post


Link to post
Share on other sites
JLogan3o13

Good addition, I always forget RegWrite is a little squirrely. The larger point stands, however; error checking needs to be done to see where the failure comes in.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
rbenner1184

14/11/2013 12:15.33 - Log Started.  SilentInstall = False
14/11/2013 12:15.35 - Uninstalling Citrix Receiver Enterprise  
14/11/2013 12:15.35 - Install returned 0, err=1, ext=2
14/11/2013 12:15.35 - Installing Citrix Receiver Enterprise  
14/11/2013 12:16.24 - Install returned 0, err=0, ext=0
14/11/2013 12:16.31 - Exiting
-
14/11/2013 12:40.18 - Log Started.  SilentInstall = False
14/11/2013 12:40.25 - Exiting
-
14/11/2013 12:42.50 - Log Started.  SilentInstall = False
14/11/2013 12:42.53 - Exiting
-
14/11/2013 12:45.38 - Log Started.  SilentInstall = False
14/11/2013 12:45.40 - Exiting
-
14/11/2013 12:47.37 - Log Started.  SilentInstall = False
14/11/2013 12:47.41 - Exiting
-
14/11/2013 13:12.48 - Log Started.  SilentInstall = False
14/11/2013 13:12.49 - Exiting
-
14/11/2013 15:12.02 - Log Started.  SilentInstall = False
14/11/2013 15:12.02 - Install returned 0, err=1, ext=87
14/11/2013 15:12.02 - Reg Write returned0, err=0, ext=0
14/11/2013 15:12.02 - Reg Write returned0, err=0, ext=0
14/11/2013 15:12.03 - Exiting

Share this post


Link to post
Share on other sites
rbenner1184

Yea maybe its the case thats wrong.

Share this post


Link to post
Share on other sites
rbenner1184

I still have no idea why the registry writing returns 0 :angry:

Share this post


Link to post
Share on other sites
JLogan3o13

You first need to narrow it down to which RegWrite fails first. Then, try a script where all you're doing is that function.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
rbenner1184

yea billo I was thinking that too. sometimes I find that autoit can be kind of buggy with the variables and macros.

Share this post


Link to post
Share on other sites
rbenner1184

i made a script that only writes to the registry with this one line of code. Still the same result :wacko:

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE \Citrix\PNAgent","ServerURL", "REG_SZ", "http://SMOCitrix.com/Citrix/PNAgent/Config.xml")

Share this post


Link to post
Share on other sites
rbenner1184

And mind you the only thing that deoesn't work in this script is the registry edit.

Share this post


Link to post
Share on other sites
rbenner1184

Is the string value backwards. This is how I always have been coding the registry write.

Share this post


Link to post
Share on other sites
JLogan3o13

 

i made a script that only writes to the registry with this one line of code. Still the same result :wacko:

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE \Citrix\PNAgent","ServerURL", "REG_SZ", "http://SMOCitrix.com/Citrix/PNAgent/Config.xml")

 

I see a space between SOFTWARE and Citrix. Is that in your script, or just how you typed it?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Jos

What does this return?

$rc = RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\PNAgent","ServerURL", "REG_SZ", "http://SMOCitrix.com/Citrix/PNAgent/Config.xml")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $rc = ' & $rc & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×