Linkfolder cant find path to delete shortcut

Antworten
Harald007
Beiträge: 1
Registriert: 26 Sep 2024, 09:50

Linkfolder cant find path to delete shortcut

Beitrag von Harald007 »

Hey guys,

I'm working on a simple opsi-script to auto install (and if installed, deinstall and reinstall) FileZilla. The issue is when trying to delete the shortcut on the desktop it cant find the path to the shortcut even though the path it is searching for and the path to the shortcut a the exact same:

Path to Shortcut: "C:\Users\Public\Desktop\FileZilla FTP Client.LNK"
Paht it cant find: "%CommonDesktopDir%\$filename$.LNK" leading according to the log to "C:\Users\Public\Desktop\FileZilla FTP Client.LNK"

here are some informations to my script:

opsi-script 4.12.14.1
encoding utf8

I'm using 2 scripts for this project, setup32.opsiscript and desub32.opsiscript. The main script is the setup32.opsiscript.


setup32.opsiscript:

Code: Alles auswählen

[Actions]
requiredWinstVersion >= "4.11.4.6"
ScriptErrorMessages=off
encoding=utf8

DefVar $UninstallProgram$
DefVar $LogDir$
DefVar $filename$
DefVar $ProductId$  
DefVar $MinimumSpace$
DefVar $InstallDir$
DefVar $ExitCode$
DefVar $Program$
DefVar $Icon$

Set $LogDir$ 		= "%opsiLogDir%"
Set $ProductId$     = "filezilla"
Set $filename$		= "FileZilla FTP Client"
Set $InstallDir$    = "%ProgramFiles64Dir%\" + $filename$
Set $MinimumSpace$  = "1 MB"
Set $Program$ 		= $InstallDir$ + "\filezilla.exe"

if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
	LogError "Not enough space on %SystemDrive%, " + $MinimumSpace$ + " on drive %SystemDrive% needed for " + $ProductId$
	isFatalError "No Space"
	; Stop process and set installation status to failed
else

	 if FileExists("%ScriptPath%\delsub32.opsiscript")
		 Sub "%ScriptPath%\delsub32.opsiscript"
		 comment "Start uninstall sub section"
	 endif
	
		
	comment "Start setup program"
	ChangeDirectory "%SCRIPTPATH%"
	Winbatch_install

	comment "Create shortcuts"
	LinkFolder_install
	
	Sub_check_exitcode
	
 endif

[Winbatch_install]
	"%SCRIPTPATH%\file1\FileZilla_3.67.1_win64_sponsored2-setup.exe" /S
	
[LinkFolder_install]
	set_basefolder common_desktopdirectory
	set_subfolder ""

	set_link
		name: $filename$
		target: $Program$
		working_dir: $InstallDir$
		icon_file: $Program$
	end_link

[Sub_check_exitcode]
comment "Test for installation success via exit code"
set $ExitCode$ = getLastExitCode
if ($ExitCode$ = "0")
	comment "Looks good: setup program gives exitcode zero"
else
	comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
	if ($ExitCode$ = "1605")
		comment "ERROR_UNKNOWN_PRODUCT	1605	This action is only valid for products that are currently installed."
		comment "Uninstall of a not installed product failed - no problem"
	else
		if ($ExitCode$ = "1641")
			comment "looks good: setup program gives exitcode 1641"
			comment "ERROR_SUCCESS_REBOOT_INITIATED	1641	The installer has initiated a restart. This message is indicative of a success."
		else
			if ($ExitCode$ = "3010")
				comment "looks good: setup program gives exitcode 3010"
				comment "ERROR_SUCCESS_REBOOT_REQUIRED	3010	A restart is required to complete the install. This message is indicative of a success."
			else
				logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
				isFatalError
			endif
		endif
	endif
endif


delsub32.opsiscript:

Code: Alles auswählen

encoding=utf8

Set $UninstallProgram$ = $InstallDir$ + "\uninstall.exe"

Message "Uninstalling " + $ProductId$ + " ..."

if FileExists($UninstallProgram$)
	comment "Uninstall program found, starting uninstall"
	Winbatch_uninstall


	comment "Delete program shortcuts"
	LinkFolder_uninstall
	
	sub_check_exitcode
	
endif

[Winbatch_uninstall]
	"$UninstallProgram$" /S

[LinkFolder_uninstall]

	set_basefolder common_desktopdirectory
	set_subfolder ""
	
	delete_element "%CommonDesktopDir%\FileZilla FTP Client.lnk"
	
[Sub_check_exitcode]
comment "Test for installation success via exit code"
set $ExitCode$ = getLastExitCode
if ($ExitCode$ = "0")
	comment "Looks good: setup program gives exitcode zero"
else
	comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
	if ($ExitCode$ = "1605")
		comment "ERROR_UNKNOWN_PRODUCT	1605	This action is only valid for products that are currently installed."
		comment "Uninstall of a not installed product failed - no problem"
	else
		if ($ExitCode$ = "1641")
			comment "looks good: setup program gives exitcode 1641"
			comment "ERROR_SUCCESS_REBOOT_INITIATED	1641	The installer has initiated a restart. This message is indicative of a success."
		else
			if ($ExitCode$ = "3010")
				comment "looks good: setup program gives exitcode 3010"
				comment "ERROR_SUCCESS_REBOOT_REQUIRED	3010	A restart is required to complete the install. This message is indicative of a success."
			else
				logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
				isFatalError
			endif
		endif
	endif
endif

Short Explanation to how the code is supposed to work:
To Install FileZilla you need to start the setup-script.
It first checks if you have the needed minimum space required for FileZilla, if you dont you get an error.
Afterwards the script starts the delsub-script
Delsub checks if the uninstall.exe file of FileZilla is already installed. If yes it starts the uninstallation of Filezilla.
After the uninstallation is finished the shortcut on the public desktop should get deleted.

This is where I have the issue of the Scriptpath not getting found

After the uninstallation the exitcode, which is btw a standard procedure (so there shouldnt be any mistakes there), should be runned
Then we should be back in the normal setup-script where Filezilla would get installed.


Details to my issue:
So basically the desktop-directory should be found by "set_basefolder common_desktopdirectory" and the file "C:\Users\Public\Desktop\FileZilla FTP Client.LNK" should get deleted
Unfortunately it does not work because the scriptpath cant be found.

This is what I get from the Logfile: Info: Link "C:\Users\Public\Desktop\FileZilla FTP Client.LNK" does not exist

And guys, I really tried everything
I tried changing the filepath just to the name of the Shortcut since the basefolder is already set to desktop - didnt work
I tried using other variables like %CurrentDesktopDir% and also changed the installation path of the shortcut to those variables - didnt work
I tried using absolute pathways instead of variables - didnt work
I checked the pathway to the shortcut a hundred times and always checked the log if they were the same
I tried using a other section and other section commands like a "Files_"-section and that also didnt work until I took at least one of the two variables out of the script. But I would like to continue with the LinkFolder section so just changing the section type is no solution to this.

Something I found is that I cant see the desktop-directory in my public-directory. It does exist since I found it in the cmd and can enter it when pasting the pathway, but there is no way of seeing it in the public directory, even when adjusting the settings to showing hidden files and directories. But this may just be a bug on the server, because I am running this project on a company server and it shouldnt be part of the issue either since I can enter the destkop directory when pasting the pathway in the pathwaybar.

Anyway, I am not sure if I just cant find a mistake or if there is a bug with the LinkFolder section in opsi. I am not that expirienced with opsi but my elder colleagues couldnt find a solution to this either.

Please tell me if you need more information provided

Thank you for sparing some time for my issue!
Best regards,
Harald
Benutzeravatar
SisterOfMercy
Beiträge: 1556
Registriert: 22 Jun 2012, 19:18

Re: Linkfolder cant find path to delete shortcut

Beitrag von SisterOfMercy »

Have you tried this?

Code: Alles auswählen

[LinkFolder_uninstall]
set_basefolder common_desktopdirectory
set_subfolder ""
delete_element "FileZilla FTP Client"
Bitte schreiben Sie Deutsch, when I'm responding in the German-speaking part of the forum!
Antworten