Solved

wnetaddconnection fails ?

Posted on 2003-11-05
3
317 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.

697 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