Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 11th July 2003, 01:47   #1
rmhost
Junior Member
 
Join Date: Jul 2003
Posts: 4
Problem with UserInfo or StrCmp or with me.

Hello,

After reading the documentation I tried to start experimenting with some of those examples that I found. Now base on the script that I experiment below, what I want to achieve is, if a user is not a member of Power User or Administrator group it will pop-up a message that says "User is just an ordinary user". Now when I try this script with a user that don't belong to Power User or Admin group, the message that pop-up is "Error! This DLL can't run under Windows 9x!".

Maybe I missed something here, why is it that my script didn't work?

Thanks!




PHP Code:
Function .onInit
  Call TestFunction
  Pop $R0
  MessageBox MB_OK 
"$R0"
  
Abort
FunctionEnd


Function TestFunction
  Push $R0

    ClearErrors
    UserInfo
::GetName
    IfErrors Win9x
    Pop 
$0
    UserInfo
::GetAccountType
    Pop 
$1
    StrCmp 
$"Admin" +3
        Strcpy $R0 
'User "$0" is in the Administrators group'
        
Goto done
    StrCmp 
$"Power" +3
        Strcpy $R0 
'User "$0" is in the Power Users group'
        
Goto done
      Strcpy $R0 
'User "$0" is just an ordinary user'
    
;  StrCmp $"User" +3
;        Strcpy $R0 'User "$0" is just a regular user'
;        Goto done
;    StrCmp $"Guest" +3
;        Strcpy $R0 'User "$0" is a guest'
;        Goto done
;    Strcpy $R0 "Unknown error"

    
Win9x:
        
# This one means you don't need to care about admin or
        # not admin because Windows 9x doesn't either
        
Strcpy $R0 "Error! This DLL can't run under Windows 9x!"

    
done:


 
Exch $R0
FunctionEnd 
rmhost is offline   Reply With Quote
Old 11th July 2003, 06:55   #2
rmhost
Junior Member
 
Join Date: Jul 2003
Posts: 4
btw I tried it on win2kpro. I'm confused with this portion. AFAIK this code:

PHP Code:
StrCmp $"Admin" +3
        Strcpy $R0 
'User "$0" is in the Administrators group'
        
Goto done
    StrCmp 
$"Power" +3
        Strcpy $R0 
'User "$0" is in the Power Users group'
        
Goto done
    Strcpy $R0 
'User "$0" is just an ordinary user' 

is similar to this: (I mean its logic)

PHP Code:
if $== "Admin"
     
$R0 "administrator group"
     
Goto done
else if $== "Power"
     
$R0 "Power User group"
     
Goto done
else
     
$R0 "is an ordinary user" 
please correct me if Im wrong. Or maybe I missed something here.
rmhost is offline   Reply With Quote
Old 11th July 2003, 11:03   #3
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
You're correct, but you forgot to jump to done after the last StrCpy which causes NSIS to continue and process Win9x and show the error message.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 13th July 2003, 23:41   #4
rmhost
Junior Member
 
Join Date: Jul 2003
Posts: 4
my bad!!!

Thanks!
rmhost is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump