Skip to content
⌘ NSIS Forum Archive

WMIC gives a Win32 Error Access Denied

4 posts

Wabiloo#

WMIC gives a Win32 Error Access Denied

Hi!

My current problem is that I need to create new users with password that never expire. In order to do that, I use the "net user" command line, but it does not allow to specify that the password never expires.

To do this last point, I use WMI, through the WMIC command line tool (installed with WinXP).
The strange thing is: if I do it from a DOS command line window, it works great.
If I do the exact same thing from a NSIS installer, it returns a "Win32 Error: Access is Denied"

The code:
    nsExec::ExecToLog 'net user NewUser "newpwd" /add /passwordreq:no /passwordchg:no /expires:never' $0
        ; ensure the password will never expire
        nsExec::ExecToLog 'wmic useraccount where name="NewUser" set passwordexpires=false' 
Anyone has any idea why that happens?

Cheers,

Wabiloo
kichik#
Works fine for me for my own user, but I didn't try to create a new user. Have you checked for a race condition? Does it still say there's a problem with permissions when you execute the installer one more time only for set the password expiry?
Wabiloo#
Now, after some more tests, I realise that there is a problem with WMIC in general when used from my installers, not just when trying to set the password expiry flag.

The first thing I do in my installer is a simple "wmic quit" so that Windows can install WMIC properly, before it gets used to do things. Even that one gives me a "Win32 Error: Access is denied"...

The user under which the installer is executes is part of the Administrators group, so I really don't understand where the error is coming from...
kichik#
Does it happen with every installer? Have you tried differently named installers? Which OS are you using? Have you tried it on other computers?