Old 31st August 2018, 12:54   #1
Junior Member
Join Date: Feb 2012
Posts: 16
Question 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"

Masternoob is offline   Reply With Quote
Old 31st August 2018, 15:31   #2
Anders's Avatar
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,926
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:
PHP Code:
System::Call 'MPR::WNetAddConnection2(t)(p r1, p 0, p 0, i 0)i.r0' 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 31st August 2018, 18:53   #3
Junior Member
Join Date: Feb 2012
Posts: 16
Works now, thank you very much
Masternoob is offline   Reply With Quote
Old 1st September 2018, 13:28   #4
Emilie Turner
Junior Member
Join Date: Aug 2018
Posts: 2
Anders, you are really smart guy!Good job!
Emilie Turner is offline   Reply With Quote
Go Back   Winamp & SHOUTcast 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