fileInstall problem

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jay lee
Posts: 83
Joined: 14 Oct 2021, 11:17

fileInstall problem

08 Dec 2021, 15:38

Hi, I made an installer for an app, which installs images. when I open the setup.ahk file it installs the images how it must be but if I open the setup.exe, the files are installed but aren't working, that means if I run an installed .png file it says: "Sorry, Photos can't open this file because the format is currently unsupported, or the file is corrupted"
do you know the problem?
other files are working!
User avatar
mikeyww
Posts: 26951
Joined: 09 Sep 2014, 18:38

Re: fileInstall problem

08 Dec 2021, 16:58

You could post your script here, along with your images, so that others can test it. Perhaps your image has been corrupted?
jay lee
Posts: 83
Joined: 14 Oct 2021, 11:17

Re: fileInstall problem

10 Dec 2021, 17:26

Code: Select all

#NoTrayIcon
#SingleInstance force
path = %ProgramFiles%\musicplayer
admin:
if not A_IsAdmin
	Run *RunAs "%A_ScriptFullPath%"
SetBatchLines, -1
SetWorkingDir %A_ScriptDir%
Menu, Tray, NoStandard
IfNotExist, C:\Program Files (x86)\Windows Media Player\wmplayer.exe
{
	FileCreateDir, %ProgramFiles%\musicplayer\
	FileCreateDir, %PorgramFiles%\musicplayer\wmp\
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\setup_wm.exe, %path%\wmp\setup_wm.exe,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\control.xml ,%path%\wmp\control.xml,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\eula.txt ,%path%\wmp\eula.txt,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\KB925749.cab ,%path%\wmp\KB925749.cab,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\LegitLibM.dll ,%path%\wmp\LegitLibM.dll,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\mymusic.inf ,%path%\wmp\mymusic.inf,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\Revert.wmz ,%path%\wmp\Revert.wmz,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\skins.inf ,%path%\wmp\skins.inf,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\syncpl01.wpl ,%path%\wmp\syncpl01.wpl,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\syncpl02.wpl ,%path%\wmp\syncpl02.wpl,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\syncpl03.wpl ,%path%\wmp\syncpl03.wpl,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\syncpl04.wpl ,%path%\wmp\syncpl04.wpl,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\syncpl05.wpl ,%path%\wmp\syncpl05.wpl,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\syncpl06.wpl ,%path%\wmp\syncpl06.wpl,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\syncpl07.wpl ,%path%\wmp\syncpl07.wpl,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\syncpl08.wpl ,%path%\wmp\syncpl08.wpl,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\syncpl09.wpl ,%path%\wmp\syncpl09.wpl,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\syncpl10.wpl ,%path%\wmp\syncpl10.wpl,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\syncpl11.wpl ,%path%\wmp\syncpl11.wpl,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\syncpl12.wpl ,%path%\wmp\syncpl12.wpl,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\umdf.exe ,%path%\wmp\umdf.exe,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\WindowsXP-MSCompPackV1-x86.exe ,%path%\wmp\WindowsXP-MSCompPackV1-x86.exe,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\wmdbexport.exe ,%path%\wmp\wmdbexport.exe,1
	FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\wmp\wmfdist11.exe ,%path%\wmp\wmfdist11.exe,1
	run, %ProgramFiles%\musicplayer\wmp\setup_wm.exe
}
FileCreateDir, %path%\
FileCreateDir, %path%\Pictures\
FileCreateDir, %path%\Pictures\folder\
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\select.png, %path%\Pictures\select.png,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\folder.png, %path%\Pictures\folder.png,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\folder\folder.ico, %path%\Pictures\folder\folder.ico,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\+10.png ,%path%\Pictures\+10.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\-10.png ,%path%\Pictures\-10.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\Caption.png ,%path%\Pictures\Caption.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\Caption2.png ,%path%\Pictures\Caption2.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\captionDown.png ,%path%\Pictures\captionDown.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\captionDown2.png ,%path%\Pictures\captionDown2.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\close.png ,%path%\Pictures\close.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\close2.png ,%path%\Pictures\close2.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\folder.png ,%path%\Pictures\folder.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\mini.png ,%path%\Pictures\mini.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\mini2.png ,%path%\Pictures\mini2.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\mute.png ,%path%\Pictures\mute.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\unmute.png ,%path%\Pictures\unmute.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\muteIcon.ico ,%path%\Pictures\muteIcon.ico ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\next.png ,%path%\Pictures\next.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\next2.png ,%path%\Pictures\next2.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\pause.png ,%path%\Pictures\pause.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\pause2.png ,%path%\Pictures\pause2.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\play.png ,%path%\Pictures\play.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\play2.png ,%path%\Pictures\play2.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\previous.png ,%path%\Pictures\previous.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\previous2.png ,%path%\Pictures\previous2.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\stop.png ,%path%\Pictures\stop.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\stop2.png ,%path%\Pictures\stop2.png ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\icon.ico ,%path%\Pictures\icon.ico ,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\VolumeUp.png ,%path%\Pictures\VolumeUp.png,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\VolumeDown.png ,%path%\Pictures\VolumeDown.png,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\loop2.png, %path%\Pictures\loop2.png,1
FileInstall, C:\Users\jakob\Desktop\mp3musicplayer\Pictures\loop.png, %path%\Pictures\loop.png, 1
FileInstall, musicplayer.exe, %path%\musicplayer.exe,1
fileInstall, song.mp3,%path%\song.mp3,1
sleep 500
Gui, 2:-Caption +AlwaysOnTop +ToolWindow
Gui, 2:Add, Text, x33 y10 c0x75f2f2, Select a path to a folder with audio files. `n(supportet files: .mp3, .wav, .m4a)
Gui, 2:Add, Button, x100 y47 w50 h30 gok, ok
Gui, 2:Color, 0x363636
x = %A_ScreenWidth%
y = %A_ScreenHeight%
x /= 2
y /= 2
y -= 40
x -= 125
xPos = %A_ScreenWidth%
xPos /= 2
xPos -= 250
yPos = %A_ScreenHeight%
yPos /= 2
yPos -= 158
song = %A_ScriptDir%\song.mp3
Gui, 1:+AlwaysOnTop -Caption
Gui, 1:Add, Text, x176 y0 w500 h17 gGuiMove BackgroundTrans c0x000000, Installer
Width := 500
check:
IfNotExist, %path%\Pictures\select.png
{
	sleep 200
	goto,check
}
Gui, 1:Add, pic, x75 y100 w250 h50 gselect, %path%\Pictures\select.png
Gui, 1:Add, Text, x4 y160 w500 h20 c0x75f2f2 vpath,
Gui, 1:Add, Text, x385 y18 w15 h15 ghelp cwhite, ?
Gui, 1:Add, Text, x350 y225 c0x75f2f2 gfinish, finish
gui, 1:color, 0x000000
gui, 1:show, w400 h250,installer
WinSet, Region, 0-0 W400 H250 R15-15, installer
WinSet,Transparent,220,installer
OnMessage(0x201, "WM_LBUTTONDOWN")
play:
soundplay, %ProgramFiles%\musicplayer\song.mp3, wait
sleep 1000
goto play
return

WM_LBUTTONDOWN() {
	PostMessage, 0xA1, 0x2,,, A
}

select:
;gui, 1:Hide
FileSelectFolder, SelectedFolder, C:
IniWrite, % SelectedFolder, %A_MyDocuments%\Musicplayerdata\musicplayer.ini, folder, 1
guiControl,,path,%SelectedFolder%
gui, 1:show, w400 h250
return

GuiMove:
PostMessage, 0xA1, 2
return

finish:
If (SelectedFolder = "") {
	Gui, 2:Show, w250 h80 x%x% y%y%, Select path
	WinSet, Region, 0-0 W400 H250 R15-15, Select path
    WinSet,Transparent,220,Select path
    Gui, 1:Hide
}
else{
	FileCreateDir, %A_MyDocuments%\Musicplayerdata
    RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.mp3\OpenWithList, a, musicplayer.exe
    RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.wav\OpenWithList, a, musicplayer.exe
    RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.m4a\OpenWithList, a, musicplayer.exe
	IniWrite, %xPos%,%A_MyDocuments%\Musicplayerdata\musicplayer.ini,xy,x
    IniWrite, %yPos%,%A_MyDocuments%\Musicplayerdata\musicplayer.ini,xy,y
    IniWrite, nothing, %A_MyDocuments%\Musicplayerdata\musicplayer.ini, loop, 1
    IniWrite, %song%, %A_MyDocuments%\Musicplayerdata\musicplayer.ini, last, 1
	Gui, 1:Hide
	run %path%\musicplayer.exe
	ExitApp
}
return

help:
Gui, 2:Show, w250 h80 x%x% y%y%, Select path
Gui, 1:Hide
return

ok:
Gui, 1:Show
Gui, 2:Hide
return

GuiClose:
Gui, 1:Show
return

GuiClose2:
Gui, 1:Show
Gui, 2:Hide
return
this is the code, its really easy and as .ahk it is working.
the images are just between 32x32 and 980x980 px. .ico are also not working when opening the .exe!
TAC109
Posts: 1112
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: fileInstall problem

10 Dec 2021, 17:40

If you are using AutoHotkey version 1.1.33.10 then you should replace Ahk2Exe.exe with the beta version that can be found at this link. It fixes an error when processing the FileInstall command.

Cheers
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
User avatar
mikeyww
Posts: 26951
Joined: 09 Sep 2014, 18:38

Re: fileInstall problem

10 Dec 2021, 17:51

Interesting issue. I was able to reproduce the problem here. I found that with the source image in the script's own directory, the error disappeared. I do not know why.

My working script:

Code: Select all

FileInstall, mikesTeleporterDSCF3352-190803_cr3.jpg, test.jpg
MsgBox % ErrorLevel
Run, %A_ScriptDir%\test.jpg
Windows Security did interfere, so I disabled it, but this was still not the problem at hand.

Edit: I had not seen TAC109's post-- and thank you!
jay lee
Posts: 83
Joined: 14 Oct 2021, 11:17

Re: fileInstall problem

10 Dec 2021, 18:03

I removed the path and it really worked.
Thank you so much :bravo:
jay lee
Posts: 83
Joined: 14 Oct 2021, 11:17

Re: fileInstall problem

10 Dec 2021, 18:06

by the way, when you compile scripts with "v1.1.33.10 A32 ANSI 32-bit.bin" you don't have to disable Windows security.
TAC109
Posts: 1112
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: fileInstall problem

10 Dec 2021, 18:23

@jay lee
You should do the Ahk2Exe replacement as I mentioned in my previous post. Then you will not have to remove the path details from the FileInstall Destination parameters, and the FileInstall commands will work correctly.

Cheers
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Billykid, haomingchen1998, Oblomov228 and 270 guests