Skip to content
⌘ NSIS Forum Archive

Connect netshare in Win 10

4 posts

Masternoob#

Connect netshare in Win 10

I am trying to connect a net share in windows with nsis. But i always get 5 as return value which means "ERROR_ACCESS_DENIED"

I wrote a test program in c++ with the exact same parameters and that works without problems on the same mashine with the same user and the same share

I tried all settings for RequestExecutionLevel but it dosn't make a difference

Is my struct wrong or does nsis run in some crazy context?
I am using the current version of NSIS3

Here is my code:
!define NETRESOURCE (i,i,i,i,p,p,p,p)
StrCpy $R5 "\\Dkendoa2\Test2"
StrCpy $R6 "Y:"
System::Call '*${NETRESOURCE}(0,0,0,0,t "$R6",t "$R5",0,0)p.r1'
System::Call 'MPR::WNetAddConnection2(p r1, t n, t n, i 0)i.r0'
MessageBox MB_OK "$0"
Anders#
If don't know if "t n" is correct, "p 0" is the same as NULL in C++ and "t n" is the same as "" and those are two different things for WNetAddConnection2 ("If lpPassword is NULL, the function uses the current default password" and "If lpPassword points to an empty string, the function does not use a password"). Also, not using the names for the RESOURCE_ values makes it hard to look at, I don't know what 0 is just by looking at your code.

Posting your C++ code would be nice...

Moving from "t n" to "p 0" might require the TCHAR hint/hack:
System::Call 'MPR::WNetAddConnection2(t)(p r1, p 0, p 0, i 0)i.r0'