Ok,
This is on a domain controller so looks like I'll have to start digging through Group Policy: "Local Policies/User Rights Assignment"
I had to add the user to: "Log on as a batch job" to get this to run initially.
I wonder if more is needed.
Actually, now that I'm trying to put this into production, the script is dying.
Seems that the unprivileged user I'm running this script as dies at this statement:
objWMIServiceRoot.ExecNotificationQueryAsync objSink, "SELECT * FROM __InstanceDeletionEvent WITHIN 1 WHERE TargetInstance ISA...
UPDATE:
Please disregard that last comment.
I had some typos when I adapted it to my application.
This code works exactly as I need.
You are the best, thank you.
Thanks for the code.
From looking this over and then trying it out real quick, I believe this allows it to run async, but it's only executed once.
I'm basically trying to execute two things at the same time and loop them forever.
One loops as fast as it can, the other loops every 5 minutes.
I have the following code that creates a process and then continually checks to make sure it's still running.
If it finds that it is closed, it creates it again and then loops forever.
Set objWMIServiceWin32Process = GetObject("WinMgmts:\\.\root\cimv2:Win32_Process")...
Fixed:
SETLOCAL ENABLEDELAYEDEXPANSION
SET strShutdownPath=%SystemRoot%\System32\
SET strShutdownProgram=shutdown.exe
SET strShutdownComment=A shutdown has been initiated. The system will shutdown in thirty (30) seconds.
IF EXIST "%SystemRoot%\System32\schtasks.exe" (
ECHO Task Scheduler...
I working on a small script here and I'm having trouble getting it to escape correctly.
Here's what I'm dealing with:
SET strShutdownPath=%SystemRoot%\System32\
SET strShutdownProgram=shutdown.exe
SET strShutdownComment=A shutdown has been initiated. The system will shutdown in thirty (30)...
Great, thanks man.
I think we now have the smallest way to do this.
Here's what it looks like all together:
Sub CreateFolderTree(strTempPath)
If Not objFSO.FolderExists(objFSO.GetParentFolderName(strTempPath)) Then
CreateFolderTree(objFSO.GetParentFolderName(strTempPath))
End If
If...
I'm tring to use this function, that I found here:
Sub CreateFolderTree(strTempPath)
On Error Resume Next
If strTempPath <> "" Then
If Not objFSO.FolderExists(objFSO.GetParentFolderName(strTempPath)) Then
Call CreateFolderTree(objFSO.GetParentFolderName(strTempPath))
Else...
I was able to figure it out.
This is the main function:
Function IsUserAdmin(strUser)
IsUserAdmin = False
Set objAdminGroup = GetObject("WinNT://" & strComputerName & "/Administrators,group")
For Each objAdminMember In objAdminGroup.Members
If objAdminMember.Name = strUser Then...
Okay, to recap here:
Nothing so far has worked the way I originally wanted to.
I've done some searching around and can't really peice together what I need to do.
Starting from scratch, here is what I would like to do:
Function IsUserAdmin(strUser)
IsUserAdmin = False
Set objAdminGroup =...
I see what you're getting at and I guess we could but it would be a mess. This needs to be installed on specific machines (I don't get to choose) for a few days then it has to be taken off untill next year when we do it again.
We would really like to have the ability to install at will.
Probaly...
I see, okay well...not very usefull since I'm tring to script an installer (don't want the end user to have to figure out all the groups he is in) but okay.
I'm tring to do this function internally without user intervention.
I guess what I really need then is some way of enumerating all the...
I think I'm missing something here...
Could you please post an example?
The way I understand it (I believe this is wrong) is that I have to hard code the group I want to check for? If that's true then it's not universal.
I understand checking a user in a group because the user name is a var...
I guess that would solve the problem but it's not the ideal solution.
I really wanted it to be more universal...so that I would be able to deploy this function in different environments without having to worry about the actual names.
No luck guys...Even the WMI method still does not detect the user as admin.
Like I said before, the user I'm tring to check is a member of a a domain group that is a member of the local admins group on the machine.
I've tried both methods (WMI and WinNT Query)
Any one else have a suggestion...
Thanks guys,
I'll give "tsuji"'s a try when I have time and let you know.
The reason I can't just do a simple check like "markdmac" suggested is becuase the user I'm tring to check is a member of a domain group that is inside the local admins group.
That's why I was going to try the WMI method...
I'm tring to work on this function but I'm getting a syntax error (0x80041002). Here is what I pieced together so far:
Function IsUserAdmin(strUser)
Set objWMI = GetObject("WinMgmts:\\" & strComputerName & "\root\cimv2")
For Each objItem In objWMI.ExecQuery("ASSOCIATORS OF...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.