Add user to local security group in Win7

The following code works fine in Windows XP to add a user to a local group. 
It will work on the machine I'm logged on to, and it will also work on 
remote machines (as a domain admin, I have permissions to modify local 
groups on all domain machines):

strDomain = "enter domain name here"
strComputer = "enter computer name here"
strGroup = "enter local group here"
strUser = "enter username here"

' Get group object
Set objGroup = GetObject("WinNT://" & strComputer & "/" & strGroup & 
",group")
' Get user object
Set objUser = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
' Add user to group
objGroup.Add(objUser.ADsPath)

HOWEVER, the results are different in Windows 7. The code above works fine 
in Windows 7 if I am running it to modify a group on a remote machine, but 
it fails with an "Access Denied" error if I run it to modify a group on the 
computer I'm currently logged on to (even though I have admin rights). The 
only way I've been able to get it to run on a Windows 7 machine I'm logged 
onto is by turning off UAC. But strangely it works fine when I run it on a 
remote Windows 7 machine, even if that remote machine has UAC on. So here is 
the million dollar question: Is there a way the script can "bypass" UAC so 
it will run without having to turn off UAC permanently?

Thanks, and I'm sorry but I actually don't have a million dollars for the 
answer! 

0
D
3/2/2010 9:32:15 PM
scripting.vbscript 564 articles. 0 followers. Follow

2 Replies
1506 Views

Similar Articles

[PageSpeed] 27

You answered this post with your “Shell.Execute question” post. If you 
execute the below script with the method you have posted in the 
"Shell.Execute question" post and enter your admin credentials again you will 
not get "Access Denied" errors.

0
Utf
3/2/2010 11:37:01 PM
The ShellExecute post is more of a workaround as I would still prefer a way 
to make it work without getting UAC involved. However, if the ShellExecute 
is the only way to do this I can live with that. But I'd still like to know 
if the "runas" username can be inserted as a parameter in the script so the 
user doesn't have to type the username every time.

Thanks...

"LikeToCode" <LikeToCode@discussions.microsoft.com> wrote in message 
news:6EF61FCE-B616-4C81-9CD8-AC1D00F29E26@microsoft.com...
> You answered this post with your “Shell.Execute question” post. If you
> execute the below script with the method you have posted in the
> "Shell.Execute question" post and enter your admin credentials again you 
> will
> not get "Access Denied" errors.
> 
0
D
3/3/2010 3:15:25 PM
Reply:

Similar Artilces:

Grouping
I am recieving emails and they seemed to be getting grouped by subject line and place in an envelop looking thing that will have a + on it if something has been added with the same subject line. The emails can be from totally different people dealing with totally different things on different days. Is there a way to stop this grouping of emails? View | Current View. Check: Show All Messages only. -- Bruce Hagen MS-MVP [Mail] Imperial Beach, CA "Confused emailer" <Confused emailer@discussions.microsoft.com> wrote in message news:A...

How to add 5 min to current time ()
Greeting, How to add 5 min to current time ()?? On Tue, 12 Feb 2008 21:23:00 -0800, ghost <ghost@discussions.microsoft.com> wrote: >Greeting, >How to add 5 min to current time ()?? DateAdd("n", 5, Now()) or for just a time value - actually a date/time value on December 30, 1899 - DateAdd("n", 5, Time()) -- John W. Vinson [MVP] ...

EzPaste-xl2ppt Excel add-in, automating the copy/paste of charts and data
Hello, This is to notify about the release of EzPaste (http:// www.EzPaste.net), an Excel add-in intended to completely automate the transfer of charts and data from Excel to PowerPoint. EzPaste identifies automatically all the charts and the tables defined in the active workbook. The user then selects which of them he wants to paste to PowerPoint=AE , and EzPaste does all the work, would you have to paste one or one hundred tables/charts at once Even if you have to paste the selected range or chart, EzPaste does it with the click of a button Sorry if this message is a bit advertising, b...

New user at Exchange 2003 cannot send mail to user at Exchange 5.5
I have 2 Exchange 5.5 and 1 Exchange 2003 in the same domain already, then I install one more Exchange 2003 in the child domain of the existing domain Then I create 1 user at child domain with mailbox in the new Exchange 2003. He find that he can only send mail to other whose mailbox in Exchange 2003. If recipient is in exchange 5.5, he cannot send to him. I have already set the ADC for the child domain. I also create the "recipient update service" for the child domain. Is any more setting needed to configurate ?? PS: In the Exchange 5.5 administrator, I can find the new user wi...

How to handle abnormal user disconnection condition from server?
I use MFC Visual C++ 4.2. I developed a simple network application to send message inter-clients and the number of clients also only a few persons ( about less than 10 persons ). I have succeeded in establishing server-client and client-server connection, sending and receiving messages from client. Now my problem are: 1. I need to send a message from a client to other client. How to know that the message I sent will be received by the correct user intended, not missed to other user? 2. How to handle the condition of unexpected user disconnection from server? E.g. : the user worksta...

RE: Use that security update
--dedtgpho Content-Type: multipart/related; boundary="yzkfzsfqtv"; type="multipart/alternative" --yzkfzsfqtv Content-Type: multipart/alternative; boundary="qeviqcxczwaquy" --qeviqcxczwaquy Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Microsoft Consumer this is the latest version of security update, the "October 2003, Cumulative Patch" update which eliminates all known security vulnerabilities affecting MS Internet Explorer, MS Outlook and MS Outlook Express as well as three newly discovered vulnerabilities. Install now to hel...

Need help grouping charts
I have identical charts which occur on multiple sheets. Is there any wa to group them for editing? When I group the sheets themselves, it seems to deactivate the charts I tried doing it with a macro as an alternative and then flipping th sheets one by one and keying the macro, but I get a message box with: "Run-time error 1004", "Unable to get the ChartObjects property of th worksheet class". Does anyone have any ideas -- Izz ----------------------------------------------------------------------- Izzy's Profile: http://www.excelforum.com/member.php?action=getin...

cannot add to archive.pst
A few months ago, I manually archived a few folders of my inbox and it worked great. I verified that the archive was there, (open outlook data file) and the archive data was in my folder list. I just tried to archive more data and it does not work. I do not get any error messages, outlook seems like it is going through the process ( a little quickly) but the files do not move. They are still in the original folders, not in archive. archive.pst did not change in size. How can I correct this? Using Outlook 2003. Archive depends on the date settings you have set, and this date is t...

seconds since 1970 and locale
When I want to get the current timestamp in the classical UNIX format "seconds since 1970", I type $a get-date -uformat %w The result is a string, with a couple of digits denoting the fractions of a second after the decimal separator. To get rid of the fractional part I can just convert the result to integer. [int]$a But: this does not work on computers where the decimal separator is a comma instead of a point due to the regional settings. I still can work around this easily using a regex: $a -replace "[\.,].*" will chop off the fractional part incl...

Alert user to check the filed when it is final
Hi, I want to create an alert to check the Final( checkbox ) field, if date_issued is enter. if date_issued is null then do nothing, In what even I have to code this and how? -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/201001/1 mls via AccessMonster.com wrote: >Hi, I want to create an alert to check the Final( checkbox ) field, if >date_issued is enter. >if date_issued is null then do nothing, In what even I have to code this and >how? Based on just that one requirement, you can use the date text b...

Multiple user names at one bank or brokerage
I have 3 accounts at one bank. I have 3 corresponding accounts set up in MS Money 2007. One of them is setup for online banking while the other two are not. I now want to set the other two up for online banking but I can't find a way to specify the unique login info for each of the other two accounts. ...

viewing a user's email account
I have been charged with reviewing a user's email activity / mailbox for a possible impropriety. Is there a way to do this from exchange, or better yet what is the best way to accomplish this steathfuly? On Mon, 23 Oct 2006 18:20:02 -0700, Rossel1 <Rossel1@discussions.microsoft.com> wrote: >I have been charged with reviewing a user's email activity / mailbox for a >possible impropriety. Is there a way to do this from exchange, or better yet >what is the best way to accomplish this steathfuly? I really hope that the users' employment contract provides for this ...

instructions disppear when users begin type (text field)
Hi all, I need to customize the outlook contact form and I want to add one text field to allow users to add details info and instruct users how to add. Instructions shows in the field and the instructions disappear when users click and begin to type. How should I do this? exchange 2003/outlook2003 Thank you. It's hard for me to visualize exactly what you're expecting to happen. If you want the instructions to stay on the screen, you could display them in a label control. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumps...

Is it possible to add a "View" button under the purchase order section?
Would be nice to have the abilty to allow someone to be able to view the purchase order as opposed to the given "new, delete, edit, or receive" buttons. This way someone who needed the information and did not have the appropriate security would not be able to delete or change the PO. I tried to CTL S the new, delete, edit and receive buttons, but that basically locks them out completely. Is this something that may be possible? You can make excel pivot table so any employee can view that worksheet from their terminal. This way you can define the fields you want to show as well ...

GP 6.0 Security
Hi! I am setting User Classes in GP 6.0 and am interested if there's any document showing relations between windows, reports, files. Information in Tools/Resource Decriptions doesn't look usefull. For example if I need to enable Trial Balance Report option for the user, which Windows, Reports and Files have to be included in order for the report to print correctly without 'not privileged' errors. What should be better approach: disable everything and add wanted options or enable everything than disable just screens that I don't want users to see. Latter looks easi...

switch users without closing program
Hi, Is there a way to switch profiles without closing Outlook 2002? Thanks, Duane ...

How did you add text into publisher, without using boxes?
how do you add text to publisher without using text boxes I suppose you could create your text as an image and insert the image into your publisher file. -- Don Vancouver, USA "Calvin Scott" <Calvin Scott@discussions.microsoft.com> wrote in message news:64D23D52-138D-47B4-B265-4A41BF14BF55@microsoft.com... > how do you add text to publisher without using text boxes Calvin Scott <Calvin Scott@discussions.microsoft.com> was very recently heard to utter: > how do you add text to publisher without using text boxes You don't. Text in Publisher has to e...

Add range options to Rec Dist report
Add additonal range options to the Receivings Distribution report - only by Audit Trail is allowed ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Businesssolutions/Community/NewsGroups/dgbrowser/en-us/default.mspx?mid=b0268d6b-4b6a-4805-9b52-e...

Security tasks necessary to post from Sales >Receivables Batch scr
I created a new role and assigned task trx-sales-022, enter/edit receipts batches. Description of task says it doesn't include posting. When I click on post on the Receivables Batch screen I get message that I don't have security to the window that is trying to open. I assume it is one of the posting journals. What tasks do I have to assign to the new role so that I can post receivables batches? This could be a really tricky question to answer depending on whether you wish to use the default tasks that are set up, or if you need to modify to make your security more specific...

reconnect to mailbox after Disabling user?
Hello, I was wondering if there is a easier way then to recycle the Exchange Services to renable a mailbox after a users mailbox has been disabled for x amount of time. I want to give access to this mailbox to another user so right now.. I simply go to Mailbox Rights -> (add the user I want to add) -> give allow rights to Read / Full but this requires a recycle of the services. Is there another way without recycling the services? G. On Mon, 23 Aug 2004 11:08:36 -0400, "Just Another Admin" <just@dmin.net> wrote: >Hello, > >I was wondering if there ...

How to let OWA users to change their password ?
How to let OWA users to change their password ? On Wed, 9 Nov 2005 01:58:03 -0800, "Enid" <Enid@discussions.microsoft.com> wrote: >How to let OWA users to change their password ? There are quite a few steps but if you follow this: http://support.microsoft.com/default.aspx?scid=kb;en-us;297121 carefuly, you'll be ok. Thanks for your information. Follow the document to enable the change password funcation, but got error when using IE6 w/ SP2 to do change password "error number : 5". It is so tricky if using FireFox, the password change is work. Any suggesti...

Cannot add user to CRM
I have trouble adding user to the CRM. I have 50 users in AD, however, when it comes to adding user in CRM, I can only choose from 15 of them. I wonder why!? I suppose I should be able to pick from all 50 users whoever is in the AD, right? If anyone have any clue on this problem and give me some feedback, I would surely appreciate that!!! CRM deployment manager will not display certain categories of users - eg if they have been migrated from NT domains or Novel NDS without passwords. Search the group archives for UserAccountControl "Martijn van Halen" <MartijnvanHalen@d...

adding same note to a group of contacts
As we know there is no histroy in CRm, can not see what has been done to contacts in past or what changes have been made. So if I whated to add the same note to a group of contacts such as : email jhfahf sent on afjak" how would I do it. Or is it just not possible. Alison, Well, you could mess with workflow and stubs do get a kludgy solution - or you could just buy VAST, the ISV add on that solves this problem, and shows you all of the historical change made to CRM! (Please excuse blatant sales pitch - but I don't get such a good leading question too often!) Dave ------...

Security Issue after upgrade to 2003
I upgraded a client to Office 2003. He then received an email with excel attachments. When he tried to open the attachment, excel gave him the error: "Cannot open file. Your antivirus has found a problem with this file" I forwarded over to my email (we are on the same network) and while I had to enable a macro, it opened fine. I downloaded both files and sent it back to him. Same message. I then disabled Norton Enterprise so that he has no AV running and tried to open it again. Same message. Everyone else I have sent it to has no trouble, and this is occurring only since t...

Group / ungroup Publisher 2007
I am trying to group 2 pictures in a text box using Publisher 2007 and Vista. The select / unselect items in the Arrange menu are greyed out. I believe I should be able to use the select tool to draw a box around the items but nothing happens when I click on it. any thoughts please Do you have a border on your page? Are you certain you are selecting all the objects? What happens if you do CTRL+A with your cursor outside the text box? -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "ancre15" <ancre15@discussions.micro...