Hi there.
I was wondering, for my backup program, if it is possible to get a list of users and use them as variables in cmd or nsis?
So i can backup all of my users with one click.
Thanks in advance.
Rob
List of all users
15 posts
Only crashing my installer.
Any variables i have to define before executing the macro?
Any variables i have to define before executing the macro?
The script mentioned in that wiki page makes uses of the NSISArray plugin and header - make sure the compiler can find those.
yes i'm not getting any error in compiling my script aswell i'm using
!include "NSISArray.nsh"
what if you try this?
!include "LogicLib.nsh"
OutFile "test.exe"
Section
SectionEnd
RequestExecutionLevel admin
Function .onInit
ReadRegStr $0 HKLM "System\CurrentControlSet\Control\ComputerName\ActiveComputerName" "ComputerName"
System::Call 'netapi32::NetUserEnum(w "\\$0",i 0,i 2,*i .R0,i ${NSIS_MAX_STRLEN}, *i .R1,*i .R2,*i .r1)i .r2'
StrCpy $R8 $R0
IntOp $R2 $R2 - 1
${ForEach} $9 0 $R2 + 1
System::Call "*$R0(w.R9)"
MessageBox MB_OK "[$R9]"
IntOp $R0 $R0 + 4
${Next}
System::Call 'netapi32.dll::NetApiBufferFree(i R8)i .R1'
FunctionEnd then i get a popup of all users. Is it also possible to display them in a list?
i got it 🙂
Ty for the help!Function users
!insertmacro MUI_HEADER_TEXT "userlist" "overzicht van alle gebruikers"
ReadRegStr $0 HKLM "System\CurrentControlSet\Control\ComputerName\ActiveComputerName" "ComputerName"
System::Call 'netapi32::NetUserEnum(w "\\$0",i 0,i 2,*i .R0,i ${NSIS_MAX_STRLEN}, *i .R1,*i .R2,*i .r1)i .r2'
StrCpy $R8 $R0
IntOp $R2 $R2 - 1
SetOutPath "$INSTDIR\"
StrCpy "$1" "$INSTDIR"
FileOpen "$0" "users.bat" "w"
FileWrite "$0" "$1$\r$\n"
${ForEach} $9 0 $R2 + 1
System::Call "*$R0(w.R9)"
FileWrite "$0" "set user$9=[$R9]$\r$\n"
IntOp $R0 $R0 + 4
${Next}
FileClose "$0"
System::Call 'netapi32.dll::NetApiBufferFree(i R8)i .R1'
FunctionEnd
Not sure why your installer hung/crashed before.. might have been NSISArray - not really needed.. the macro should use a callback function instead and let the user decide what to do with the info. I might propose an edit to that wiki page later.
Anyway - glad it's all sorted 🙂
Anyway - glad it's all sorted 🙂
one more issue...
i do this now:
Is there any workaround?
i do this now:
But i cant recall my defined users.
${ForEach} $9 0 $R2 + 1
System::Call "*$R0(w.R9)"
!define user$9 $R9
IntOp $R0 $R0 + 4
${Next}
Is there any workaround?
Defines are created at compile-time, rather than runtime. If you need the list of users the installer is run on, use a variable instead. Or fall back to the text file output and read from that, or use NSISArray to store each user in an array (which the original macro did) 🙂Originally Posted by xreboot View Postone more issue...
But i cant recall my defined users.
!define user$9 $R9
Is there any workaround?
I have not been keeping up with Afro's NSISArray array plugin development, but I am pretty sure that the wiki page macro works with version 1.x ...
Here is what also works with v.2.3 that I just tested:
First some definitions ...
CF
Here is what also works with v.2.3 that I just tested:
First some definitions ...
Then the macro:!define NERR_Success 0
!define NERR_More_Data 234
!define strNET_DISPLAY_USER '(w,w,i,w,i,i)i'
Call the macro (for the local machine):!macro EnumLocalUsers SERVER_NAME ARRAY_NAME ERRORFLAG
!define Index "Line${__LINE__}"
StrCpy ${ERRORFLAG} 0
; $R0 gets number of entries, $R1 is an array of NET_DISPLAY_USER structures
System::Call /NOUNLOAD 'netapi32::NetQueryDisplayInformation(w "${SERVER_NAME}",i 1,i 0,i 99, i ${NSIS_MAX_STRLEN},*i .R2,*i .R0)i.r5'
StrCmp $5 ${NERR_Success} ${Index}_No_Error
StrCmp $5 ${NERR_More_Data} ${Index}_No_Error ${Index}_Error
${Index}_Error:
StrCpy ${ERRORFLAG} 1
Goto ${Index}_End
${Index}_No_Error:
StrCpy $R7 $R0
NSISArray::New /NOUNLOAD ${ARRAY_NAME} $R2 2
StrCpy $2 0
${Index}_Feed:
StrCmp $2 $R2 ${Index}_Stop
System::Call '*$R0${strNET_DISPLAY_USER}(.R9,,,,,)'
IntOp $R0 $R0 + 24
NSISArray::Write /NOUNLOAD ${ARRAY_NAME} $2 '$R9'
IntOp $2 $2 + 1
Goto ${Index}_Feed
${Index}_Stop:
NSISArray::FreeUnusedMem /NOUNLOAD
${Index}_End:
System::Call /NOUNLOAD 'netapi32::NetApiBufferFree(i R7)i.r5'
!undef Index
!macroend
and if I debug I get all the local users in the array object:StrCpy $1 0
!insertmacro EnumLocalUsers "" LocalUsers $1
${If} $1 = 1
MessageBox MB_OK|MB_ICONSTOP|MB_TOPMOST "Error on the API call!"
${EndIf}
Hope this helps,NSISArray:😁ebug /NOUNLOAD LocalUsers
CF
Alright, i got it now, but how can i exclude stuff like SUPPORT_388945a0
?
?
v2.3 had a MS VC90 CRT dependency (in its XML manifest) which I've now sorted in v2.4. Let me know if the crashing is fixed.
Stu
Stu