Solved

wnetaddconnection fails ?

Posted on 2003-11-05
3
312 Views
Last Modified: 2012-06-27
hi,
   i am writing a small code to have remote shutdown of winNT/2k servers.
hence i first tried to write using Wnetaddconnection to get connected using admin/password , since directly using initiatesystemshutdown API doestn allow me to get priviliege to shutdown.(i dont know why)
i tried to give the privilage using lookupprivilage,accesstoken api's but failed.
  my now probs is Wnetaddconnection fails and gives error values as 67(i cant trace what it is using wnetgetlasterror). may be  NETRESOURCE.lpszRemotename is wrong.
so can u provide some sample code to do such a thing
kiran
0
Comment
Question by:kirannapit
3 Comments
 
LVL 3

Accepted Solution

by:
Madz earned 76 total points
ID: 9693344
Try using NetUseAdd to add a connection to a remote resource.

USE_INFO_2 ui2;

ZeroMemory(&ui2, sizeof(ui2));

ui2.ui2_local = NULL;
ui2.ui2_remote = szRemoteResource; // Your remote resource path. In your case it could be \\<server>\IPC$
ui2.ui2_asg_type = USE_IPC;
ui2.ui2_password = ui2.ui2_username = ui2.ui2_domainname = L"";

nas = NetUseAdd(NULL, 2, (LPBYTE)&ui2, NULL);

Madz
0
 
LVL 9

Expert Comment

by:tinchos
ID: 10242565
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: Madz {http:#9693344}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now