Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

wnetaddconnection fails ?

Posted on 2003-11-05
3
Medium Priority
?
325 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 304 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.
Suggested Courses
Course of the Month10 days, 9 hours left to enroll

885 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