creating directories on remote nt machines -> netshareadd ?

hi guys,
I would like to create a directory on another nt machine. currently i use netshareadd and then
move a file there, but i would like to create a directory
first and then copy the file to that directory if this
is possible.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

What about simply using 'CreateDirectory ( "\\\\server\\shared_vol\\directory", NULL);'?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
boyracerAuthor Commented:
Will try it... I also read the documentation on
CreateDirectory but was not sure if it also
works on remote hosts.

-> So it is required that for example
c: is shared or can I call netshareadd first
instead so that c becomes shared ?
>>Will try it...

Don't accept answers before trying it! (nope, it'll work ;-)

Perhaps I haven't been clear enough - the directory doesn't necessarily have to be shared 'directly', an admin share (e.g. 'c$') will also work. If you're receiving 'ERROR_ACCESS_DENIED', you'll have to gather the credentials from the remote machine by using 'WNetAddConnection2()', e.g.


    ZeroMemory  (   &nr,    sizeof  (   NETRESOURCE));

    nr.dwType           =   RESOURCETYPE_DISK;
    nr.lpLocalName      =   L"";
    nr.lpRemoteName     =   "\\\\server\\path";

    dwRes   =   WNetAddConnection2  (   &nr,

    if  (   dwRes)
            //  error

Caveat: Win9x only uses the name of the logged-on user, specifying a different name does not remedy this. However, specifying a different password is allowed (as the user might have a different one for the network share). See also 
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

boyracerAuthor Commented:
mal kurz auf deutsch ...

ich verstehe es doch aber richtig,
dass ich ein konekt nur zu einem
shared / freigegebenen drive machen kann, oder.

wenn ich also gerne
ein directory "test" unter c:\progra~1\
erstellen moechte muss progra~1 geshared sein !?

kann man denn auch von "aussen" ein
drive sharen wenn es das noch nicht ist ?
-> muesste man dazu die registry eines
remote rechners aendern
(nach RegConnectRegistry zb )

boyracerAuthor Commented:
Sorry fuer die Verspaetung, aber Freitags war immer nur 'internal server error' & ich war krank uebers Wochenende

Im kurzen:

CreateDirectory ( "\\\\server\\c$\\programs\\newdir", NULL);

muss auch tun...

>>kann man denn auch von "aussen" ein
>>drive sharen wenn es das noch nicht
>>ist ?

Ja, klar, mit 'NetShareAdd()'
boyracerAuthor Commented:
boyracerAuthor Commented:

ich habe es die letzten tage leider vergeblich versucht. leider bekomme ich immer Access denied :-( damit ich verschiedenes ausprobieren
boyracerAuthor Commented:
sorry, ich kann hier nix mehr eingeben
bekomme immer server error :-(
Internal server error - Weil Umlaute unerwuenscht ;-)
boyracerAuthor Commented:

jetzt bekomme ich einen error 1219:

macht das mehr sinn ?
(bei benutzung des Administrator accounts
der remote machine)

danke fuer die hilfe,
boyracerAuthor Commented:
Hallo JKR,
es funktioniert jetzt.
Grund war eine verkappte NT installation...
Hat ja nur eine Ewigkeit gedauert es rauszufinden...

Vielen Dank,
Gruss aus dem kalt ekligen Mannheim.
No, prima! Wusste doch, daß es tun muß ;-)

BTW: In Heilbronn isses wettermäßig nich' viel besser...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.