I have a working design (still in process) and I wanted to test the initial design before I got too far along. The project still works fine on my development system but when I move the exe file to another computer the installation fails when trying to write a menu.ini file.
I assume this is a very basic function/feature so I am confused as to why it might be failing. On the development computer everything runs fine. On the new target computer the menuml.ini file never gets created.
Why is the project not portable to a new computer?
Here are some specifics:
!define pantsMenuIni "C:Tools\ConfigPC\menuml.ini"
Function .onInit
StrCpy $INSTDIR "C:\Tools\ConfigPC"
CreateDirectory "C:\Tools"
CreateDirectory "$INSTDIR"
sleep 1000
Delete "$INSTDIR\InstallLog.log"
${LogSetFileName} "$INSTDIR\InstallLog.log"
${LogSetOn}
${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6
; $0="01" day
; $1="04" month
; $2="2005" year
; $3="Friday" day of week name
; $4="16" hour
; $5="05" minute
; $6="50" seconds
${LogText} "#################### Function .onInit"
${LogText} 'Date=$0/$1/$2 ($3)'
${LogText} 'Time=$4:$5:$6'
${LogText} "$\r$\n"
${LogText} "Menu File: ${pantsMenuIni}"
!insertmacro MUI_LANGDLL_DISPLAY
;Write default menuml file
Call WriteMenuFile
;Update menuml file from old Config PC INI files
Call UpdateMenuFile
FunctionEnd
Function WriteMenuFile
${LogText} "#################### Function WriteMenuFile"
${LogText} "Menu File: ${pantsMenuIni}"
FileOpen $0 "${pantsMenuIni}" w
FileWrite $0 ""
FileClose $0
;Settings
WriteIniStr ${pantsMenuIni} "Settings" "NumFields" "5"
WriteIniStr ${pantsMenuIni} "Settings" "State" "0"
;Field 1 - Border Group Box
WriteIniStr ${pantsMenuIni} "Field 1" "Type" "groupbox"
WriteIniStr ${pantsMenuIni} "Field 1" "Left" "0"
WriteIniStr ${pantsMenuIni} "Field 1" "Right" "-1"
WriteIniStr ${pantsMenuIni} "Field 1" "Top" "0"
WriteIniStr ${pantsMenuIni} "Field 1" "Bottom" "-11"
WriteIniStr ${pantsMenuIni} "Field 1" "Text" "Select PANTS Application and Version"
WriteIniStr ${pantsMenuIni} "Field 1" "HWND" "1709234"
;Field 2 - Application Name Label
WriteIniStr ${pantsMenuIni} "Field 2" "Type" "label"
WriteIniStr ${pantsMenuIni} "Field 2" "Left" "40"
WriteIniStr ${pantsMenuIni} "Field 2" "Right" "-40"
WriteIniStr ${pantsMenuIni} "Field 2" "Top" "20"
WriteIniStr ${pantsMenuIni} "Field 2" "Bottom" "30"
WriteIniStr ${pantsMenuIni} "Field 2" "Text" "$\"Application$\""
WriteIniStr ${pantsMenuIni} "Field 2" "HWND" "1316102"
;Field 3 - Application Name Drop List
WriteIniStr ${pantsMenuIni} "Field 3" "Type" "DROPLIST"
WriteIniStr ${pantsMenuIni} "Field 3" "ListItems" "Select Application"
WriteIniStr ${pantsMenuIni} "Field 3" "State" "$\"Select Application$\""
WriteIniStr ${pantsMenuIni} "Field 3" "Left" "40"
WriteIniStr ${pantsMenuIni} "Field 3" "Right" "-40"
WriteIniStr ${pantsMenuIni} "Field 3" "Top" "30"
WriteIniStr ${pantsMenuIni} "Field 3" "Bottom" "130"
WriteIniStr ${pantsMenuIni} "Field 3" "Flags" "NOTIFY"
WriteIniStr ${pantsMenuIni} "Field 3" "HWND" "1314966"
;Field 4 - Application Version Label
WriteIniStr ${pantsMenuIni} "Field 4" "Type" "label"
WriteIniStr ${pantsMenuIni} "Field 4" "Left" "40"
WriteIniStr ${pantsMenuIni} "Field 4" "Right" "-40"
WriteIniStr ${pantsMenuIni} "Field 4" "Top" "50"
WriteIniStr ${pantsMenuIni} "Field 4" "Bottom" "60"
WriteIniStr ${pantsMenuIni} "Field 4" "Text" "$\"Version$\""
WriteIniStr ${pantsMenuIni} "Field 4" "HWND" "1445394"
;Field 5 - Application Version Drop List
WriteIniStr ${pantsMenuIni} "Field 5" "Type" "DROPLIST"
WriteIniStr ${pantsMenuIni} "Field 5" "ListItems" "Select Version"
WriteIniStr ${pantsMenuIni} "Field 5" "State" "$\"Select Version$\""
WriteIniStr ${pantsMenuIni} "Field 5" "Left" "40"
WriteIniStr ${pantsMenuIni} "Field 5" "Right" "-40"
WriteIniStr ${pantsMenuIni} "Field 5" "Top" "60"
WriteIniStr ${pantsMenuIni} "Field 5" "Bottom" "160"
WriteIniStr ${pantsMenuIni} "Field 5" "Flags" "FOCUS"
WriteIniStr ${pantsMenuIni} "Field 5" "HWND" "2364602"
FileOpen $0 "${pantsMenuIni}" r
FWLOOP:
ClearErrors
FileRead $0 $1
${LogText} "Menu File LINE: $1"
IfErrors fwclose
Goto FWLOOP
fwclose:
FileClose $0
WriteIniStr ${pantsMenuIni} "Settings" "WriteMenuFile" "Done"
FunctionEnd
Partial "good" log:
#################### Function WriteMenuFile
Menu File: C:Tools\ConfigPC\menuml.ini
Menu File LINE: [Settings]
Menu File LINE: NumFields=5
Menu File LINE: State=0
Menu File LINE: [Field 1]
Menu File LINE: Type=groupbox
Menu File LINE: Left=0
Menu File LINE: Right=-1
Menu File LINE: Top=0
Menu File LINE: Bottom=-11
Menu File LINE: Text=Select PANTS Application and Version
Menu File LINE: HWND=1709234
...
#################### Function UpdateMenuFile
Partial "bad" log
#################### Function .onInit
Date=01/08/2017 (Tuesday)
Time=11:14:57
Menu File: C:Tools\ConfigPC\menuml.ini
#################### Function WriteMenuFile
Menu File: C:Tools\ConfigPC\menuml.ini
Menu File LINE:
#################### Function UpdateMenuFile
Portability
10 posts
Maybe you don't have write access to C:?
Highly unlikely this is a problem unless the installer retains some form of permissions relative to the compile process. I am able to create the log file, the uninstall file, and a handful of intermediate text files, all in the same directory. The only missing file is the menu INI file.
Forgot to add that the directories are deleted during uninstall so I am also able to create the required directories from C:\ as well.
You could try Process Monitor.
To actually test this myself I would need a minimal but complete example I could actually compile and I need to know the Windows and NSIS versions and if it is UAC elevated...
To actually test this myself I would need a minimal but complete example I could actually compile and I need to know the Windows and NSIS versions and if it is UAC elevated...
C: OR C:\
i change first line
!define pantsMenuIni "C:Tools\ConfigPC\menuml.ini"
!define pantsMenuIni "C:\Tools\ConfigPC\menuml.ini"
and menuml.ini was created!
!include "GetTime.nsh"
!include "mui2.nsh"
!define pantsMenuIni "C:\Tools\ConfigPC\menuml.ini"
# TextLog.nsh v1.1 - 2005-12-26
# Written by Mike Schinkel [http://www.mikeschinkel.com/blog/]
Var /GLOBAL __TextLog_FileHandle
Var /GLOBAL __TextLog_FileName
Var /GLOBAL __TextLog_State
!define LogText '!insertmacro LogTextCall'
!macro LogTextCall _text
Push "${_text}"
Call LogText
!macroend
Function LogText
Push $0 ; pABC -> 0pABC
Exch ; 0pABC -> p0ABC
Pop $0 ; p0ABC -> 0ABC
FileWrite $__TextLog_FileHandle "$0$\r$\n"
Pop $0 ; 0ABC -> ABC
FunctionEnd
!define LogSetFileName '!insertmacro LogSetFileNameCall'
!macro LogSetFileNameCall _filename
Push "${_filename}"
Call LogSetFileName
!macroend
Function LogSetFileName
Push $0 ; pABC -> 0pABC
Exch ; 0pABC -> p0ABC
Pop $0 ; p0ABC -> 0ABC
StrCpy $__TextLog_FileName "$0"
StrCmp $__TextLog_State "open" +1 +3
Call LogSetOff
Call LogSetOn
Pop $0 ; 0ABC -> ABC
FunctionEnd
!define LogSetOn '!insertmacro LogSetOnCall'
!macro LogSetOnCall
Call LogSetOn
!macroend
Function LogSetOn
StrCmp $__TextLog_FileName "" +1 AlreadySet
StrCpy $__TextLog_FileName "$INSTDIR\install.log"
AlreadySet:
StrCmp $__TextLog_State "open" +2
FileOpen $__TextLog_FileHandle "$__TextLog_FileName" a
StrCpy $__TextLog_State "open"
FunctionEnd
!define LogSetOff '!insertmacro LogSetOffCall'
!macro LogSetOffCall
Call LogSetOff
!macroend
Function LogSetOff
StrCmp $__TextLog_State "open" +1 +2
FileClose $__TextLog_FileHandle
StrCpy $__TextLog_State ""
FunctionEnd
Function .onInit
StrCpy $INSTDIR "C:\Tools\ConfigPC"
CreateDirectory "C:\Tools"
CreateDirectory "$INSTDIR"
sleep 1000
Delete "$INSTDIR\InstallLog.log"
${LogSetFileName} "$INSTDIR\InstallLog.log"
${LogSetOn}
${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6
; $0="01" day
; $1="04" month
; $2="2005" year
; $3="Friday" day of week name
; $4="16" hour
; $5="05" minute
; $6="50" seconds
${LogText} "#################### Function .onInit"
${LogText} 'Date=$0/$1/$2 ($3)'
${LogText} 'Time=$4:$5:$6'
${LogText} "$\r$\n"
${LogText} "Menu File: ${pantsMenuIni}"
!insertmacro MUI_LANGDLL_DISPLAY
;Write default menuml file
Call WriteMenuFile
;Update menuml file from old Config PC INI files
Call UpdateMenuFile
FunctionEnd
Function WriteMenuFile
${LogText} "#################### Function WriteMenuFile"
${LogText} "Menu File: ${pantsMenuIni}"
FileOpen $0 "${pantsMenuIni}" w
FileWrite $0 ""
FileClose $0
;Settings
WriteIniStr ${pantsMenuIni} "Settings" "NumFields" "5"
WriteIniStr ${pantsMenuIni} "Settings" "State" "0"
;Field 1 - Border Group Box
WriteIniStr ${pantsMenuIni} "Field 1" "Type" "groupbox"
WriteIniStr ${pantsMenuIni} "Field 1" "Left" "0"
WriteIniStr ${pantsMenuIni} "Field 1" "Right" "-1"
WriteIniStr ${pantsMenuIni} "Field 1" "Top" "0"
WriteIniStr ${pantsMenuIni} "Field 1" "Bottom" "-11"
WriteIniStr ${pantsMenuIni} "Field 1" "Text" "Select PANTS Application and Version"
WriteIniStr ${pantsMenuIni} "Field 1" "HWND" "1709234"
;Field 2 - Application Name Label
WriteIniStr ${pantsMenuIni} "Field 2" "Type" "label"
WriteIniStr ${pantsMenuIni} "Field 2" "Left" "40"
WriteIniStr ${pantsMenuIni} "Field 2" "Right" "-40"
WriteIniStr ${pantsMenuIni} "Field 2" "Top" "20"
WriteIniStr ${pantsMenuIni} "Field 2" "Bottom" "30"
WriteIniStr ${pantsMenuIni} "Field 2" "Text" "$\"Application$\""
WriteIniStr ${pantsMenuIni} "Field 2" "HWND" "1316102"
;Field 3 - Application Name Drop List
WriteIniStr ${pantsMenuIni} "Field 3" "Type" "DROPLIST"
WriteIniStr ${pantsMenuIni} "Field 3" "ListItems" "Select Application"
WriteIniStr ${pantsMenuIni} "Field 3" "State" "$\"Select Application$\""
WriteIniStr ${pantsMenuIni} "Field 3" "Left" "40"
WriteIniStr ${pantsMenuIni} "Field 3" "Right" "-40"
WriteIniStr ${pantsMenuIni} "Field 3" "Top" "30"
WriteIniStr ${pantsMenuIni} "Field 3" "Bottom" "130"
WriteIniStr ${pantsMenuIni} "Field 3" "Flags" "NOTIFY"
WriteIniStr ${pantsMenuIni} "Field 3" "HWND" "1314966"
;Field 4 - Application Version Label
WriteIniStr ${pantsMenuIni} "Field 4" "Type" "label"
WriteIniStr ${pantsMenuIni} "Field 4" "Left" "40"
WriteIniStr ${pantsMenuIni} "Field 4" "Right" "-40"
WriteIniStr ${pantsMenuIni} "Field 4" "Top" "50"
WriteIniStr ${pantsMenuIni} "Field 4" "Bottom" "60"
WriteIniStr ${pantsMenuIni} "Field 4" "Text" "$\"Version$\""
WriteIniStr ${pantsMenuIni} "Field 4" "HWND" "1445394"
;Field 5 - Application Version Drop List
WriteIniStr ${pantsMenuIni} "Field 5" "Type" "DROPLIST"
WriteIniStr ${pantsMenuIni} "Field 5" "ListItems" "Select Version"
WriteIniStr ${pantsMenuIni} "Field 5" "State" "$\"Select Version$\""
WriteIniStr ${pantsMenuIni} "Field 5" "Left" "40"
WriteIniStr ${pantsMenuIni} "Field 5" "Right" "-40"
WriteIniStr ${pantsMenuIni} "Field 5" "Top" "60"
WriteIniStr ${pantsMenuIni} "Field 5" "Bottom" "160"
WriteIniStr ${pantsMenuIni} "Field 5" "Flags" "FOCUS"
WriteIniStr ${pantsMenuIni} "Field 5" "HWND" "2364602"
FileOpen $0 "${pantsMenuIni}" r
FWLOOP:
ClearErrors
FileRead $0 $1
${LogText} "Menu File LINE: $1"
IfErrors fwclose
Goto FWLOOP
fwclose:
FileClose $0
WriteIniStr ${pantsMenuIni} "Settings" "WriteMenuFile" "Done"
FunctionEnd
Function UpdateMenuFile
FunctionEnd
Section
SectionEnd
also i change UAC to highest level
but menuml.ini created!
UAC is disabled
Windows 7 Pro
NSIS 3.02
I would need to create a minimal example file so putting it off for now.
Update:
Works from the following disks and directories.
D:\NSIS\Projects\ConfigPC (project build directory)
D:\
C:\
Does not work from the following directories.
C:\Users\tester\Desktop
C:\Users\tester\Documents
This is too strange to be a result of SW version or OS version. Even seems odd to be a function of some relative path issue. In order to debug this I need some visibility into the first File open and write.
FileOpen $0 "${pantsMenuIni}" w
FileWrite $0 ""
FileClose $0
Also this is consistent on 3 different computers with the exception of disk D:\ which is only on my development computer. I removed the NSIS program directory to make sure it was not related to the NSIS application installation location (thought it might be that the compiled install app still needed some include or plugin file).
Windows 7 Pro
NSIS 3.02
I would need to create a minimal example file so putting it off for now.
Update:
Works from the following disks and directories.
D:\NSIS\Projects\ConfigPC (project build directory)
D:\
C:\
Does not work from the following directories.
C:\Users\tester\Desktop
C:\Users\tester\Documents
This is too strange to be a result of SW version or OS version. Even seems odd to be a function of some relative path issue. In order to debug this I need some visibility into the first File open and write.
FileOpen $0 "${pantsMenuIni}" w
FileWrite $0 ""
FileClose $0
Also this is consistent on 3 different computers with the exception of disk D:\ which is only on my development computer. I removed the NSIS program directory to make sure it was not related to the NSIS application installation location (thought it might be that the compiled install app still needed some include or plugin file).
Wow, I missed that subtle difference. Even more odd, it worked in most cases. I will do some additional testing to see if this resolves my issues, thanks.
I still find it odd that it ever worked but the solution was as simple as you pointed out.
Thanks
Thanks
c:xyz is xyz in the current directory of drive c. If you think that is crazy, c:d:e is a legal path in some places.