Sign in to follow this  
Followers 0
SMurphy

IsAdmin

8 posts in this topic

#1 ·  Posted (edited)

Okay, as I continue forward on my Novell to AD migration VBScript, I've hit a small snag. At a previous client, they had AutoIT and had a .exe called IsAdmin. It returned a 1 or a 0 depending on the rights of the user. I see that this is a function in AutoIT and have even been able to test it successfully using...

if IsAdmin <> 0 then
msgbox(0,"","You have admin rights")
end if

However, what I really want is an executable that I can call from VBScript and then capture the return code like this...

Set oShell = CreateObject("Wscript.Shell")

rcIsAdmin = oShell.Run("Isadmin.exe -q", 0, True)

If rcIsAdmin = 0 Then
    Wscript.Echo "You have do not have admin rights"
    WScript.Quit
End If

Thanks,

Sean

Edited by SMurphy

Share this post


Link to post
Share on other sites



Okay, as I continue forward on my Novell to AD migration VBScript, I've hit a small snag. At a previous client, they had AutoIT and had a .exe called IsAdmin. It returned a 1 or a 0 depending on the rights of the user. I see that this is a function in AutoIT and have even been able to test it successfully using...

if IsAdmin <> 0 then
msgbox(0,"","You have admin rights")
end if

However, what I really want is an executable that I can call from VBScript and then capture the return code like this...

Set oShell = CreateObject("Wscript.Shell")

rcIsAdmin = oShell.Run("Isadmin.exe -q", 0, True)

If rcIsAdmin = 0 Then
    Wscript.Echo "You have do not have admin rights"
    WScript.Quit
End If

Thanks,

Sean

Did you try RunWait() ? should return the RC of the program ...

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Did you try RunWait() ? should return the RC of the program ...

Hmm... No, I'm writing VBScript.. I just want to make the IsAdmin funtion into an EXE that returns the same RC as the function. Then I will call that EXE from within my VBScript.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hmm... No, I'm writing VBScript.. I just want to make the IsAdmin funtion into an EXE that returns the same RC as the function. Then I will call that EXE from within my VBScript.

you mean an autoit3 compiled script return it ?

This should do that:

Return isAdmin()

Or use AutoIt3X ...

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Okay... so, I created an AutoIT script...

Return is IsAdmin()

and it echos "ADMIN".

So, the function appears to work, but when I complile it to an EXE, it's returning the wrong RC.

Ideas?

Edited by SMurphy

Share this post


Link to post
Share on other sites

If it's any consolation, I wish Return worked like that from global scope but it was deemed superfluous so I didn't bother implementing it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0