Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

wnetaddconnection fails ?

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

721 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