Here is a quick example to access network shares. The code is based on some MSDN examples.
Usage: ConnShare letter remotename username password
ConnShare.exe Z: \\server\share Administrator p@ssw0rd!
interesting - and educational, Erol :t
Well done, Erol. :t Thank you.
Gunther
Crispy and clear, Erol - really nice :t
Here is the Masm version, with formatted errors instead of the numbers. Can't test it right now because I don't have a network, but it should work, too ;-)
include \masm32\MasmBasic\MasmBasic.inc ; download (http://masm32.com/board/index.php?topic=94.0)
uselib mpr
.data?
nr NETRESOURCE <?>
Init
push eax
invoke CommandLineToArgvW, rv(GetCommandLineW), esp
pop ecx
.if ecx==5
mov nr.dwType, RESOURCETYPE_ANY
mov nr.lpLocalName, CL$(1)
mov nr.lpRemoteName, CL$(2)
and nr.dwType, 0
push FALSE
push CL$(3)
push CL$(4)
lea eax, nr
push eax
call WNetAddConnection2
.if eax == NO_ERROR
Print "Connection added: ", CL$(2)
.else
Print "Error: ", Err$()
.endif
.else
wPrint "ConnShare V1.0", wCrLf$, wCrLf$, "Usage: ConnShare letter remotename username password"
.endif
wInkey
Exit
end start
OPT_Arg1 Z: \\server\share Administrator p@ssw0rd ; for testing (RichMasm sets arguments this way)
For me, it returns "Error: Nessun provider di rete ha accettato il percorso di rete specificato.", which is for Google translate "Error: No network provider accepted the given network path.".
G**gle query
indexof: /share
will give you lots of shared folders on the internet ;)
Thank you, Jochen for the MasmBasic version. Works fine for me.
Gunther
I have no experience with shared folders.
Does one of you have a concrete commandline that works?
Plus one for WNetCancelConnection2?
i don't really know of a command-line interface for working with shared folders
i do know that if you want to share a folder, you can right-click/properties/sharing tab and do it that way
i suspect the info is buried in NTFS System Volume Information or, more likely, in the registry
it may be a group policy thing - i never dug into it :P
according to technet, "net" works if Run As Admin
http://technet.microsoft.com/en-us/library/cc770880.aspx#BKMK_cp (http://technet.microsoft.com/en-us/library/cc770880.aspx#BKMK_cp)
Quote from: dedndave on November 10, 2013, 07:00:32 AM
i don't really know of a command-line interface for working with shared folders
Hi,
If a resource is already shared, you can use the "NET USE"
command to access it from a command line. Try "NET HELP"
and "NET HELP USE" to maximize the local entropy. "NET View"
to see shared stuff.
Cheers,
Steve N.
with a little further reading, i find that "net is old technology - not very reliable"
Dave,
Quote from: dedndave on November 10, 2013, 07:23:27 AM
with a little further reading, i find that "net is old technology - not very reliable"
that's right. Here's a short summary. (http://www.computerhope.com/nethlp.htm#01)
Gunther
Quote from: Gunther on November 10, 2013, 08:01:56 AM
Dave,
Quote from: dedndave on November 10, 2013, 07:23:27 AM
with a little further reading, i find that "net is old technology - not very reliable"
that's right. Here's a short summary. (http://www.computerhope.com/nethlp.htm#01)
Gunther
Hi Gunther and Dave,
I have to disagree. The net command does perfectly its job. I use it everyday at work to assign letters to network shares and I didn't experience any problem with the net command.
well - i tried
net view
i got an error 6118
which may be a valid error, as i have no shares
Hi Dave,
The net command is using the SMB protocol. Maybe, you have a firewall \ AV issue blocking the communication.
Hi Erol,
no offense, I haven't used SMB since version 2.0. In the late 80s and in the 90s SMB was sometimes a bit tricky. That was my point. But you're right: it's under active development now.
Gunther