CraigCustom Posted May 3, 2013 Share Posted May 3, 2013 I can't seem to get the Isadmin to work on my script. I'm running windows 7 pro and I have an windows xp machine that I have been testing this on too, and it just hangs there and not works. Does any have any idea's on how to fix this problem? expandcollapse popupIf DirCopy("N:\software\new_system\Teamviewer", "C:\TeamViewer", 1) Then FileCopy("C:\Teamviewer\TeamViewer_Host_Setup-ckj.exe", "C:\Documents and Settings\cbungard\Desktop", 1) Sleep(1000) EndIf If IsAdmin() Then ShellExecute("C:\Documents and Settings\cbungard\Desktop\TeamViewer_Host_Setup-ckj.exe") WinWait("Open File - Security Warning", "Name:") WinActivate("Open File - Security Warning", "Name:") ControlClick("Open File - Security Warning", "Name:", 4423) WinWait("TeamViewer 7 Host Setup", "Welcome to TeamViewer 7 Host") WinActivate("TeamViewer 7 Host Setup", "Welcome to TeamViewer 7 Host") ControlClick("TeamViewer 7 Host Setup", "Welcome to TeamViewer 7 Host", 1) WinWait("TeamViewer 7 Host Setup", "How do you want to use TeamViewer") WinActivate("TeamViewer 7 Host Setup", "How do you want to use TeamViewer") ControlClick("TeamViewer 7 Host Setup", "How do you want to use TeamViewer", 1201) ControlClick("TeamViewer 7 Host Setup", "How do you want to use TeamViewer", 1) WinWait("TeamViewer 7 Host Setup", "Press Page Down to see the rest of the agreement.") WinActivate("TeamViewer 7 Host Setup", "Press Page Down to see the rest of the agreement.") ControlClick("TeamViewer 7 Host Setup", "Press Page Down to see the rest of the agreement.", 1203) ControlClick("TeamViewer 7 Host Setup", "Press Page Down to see the rest of the agreement.", 1) WinWait("TeamViewer 7 Host Setup", "You have to supply a password.") WinActivate("TeamViewer 7 Host Setup", "You have to supply a password.") ControlSetText("TeamViewer 7 Host Setup", "You have to supply a password.", 1200, "1234") ControlSetText("TeamViewer 7 Host Setup", "You have to supply a password.", 1201, "1234") ControlClick("TeamViewer 7 Host Setup", "You have to supply a password.", 1) Sleep(9000) EndIf If ShellExecute("C:\TeamViewer\TeamViewerRegistryScript.cmd") Then Sleep(10000) EndIf If IsAdmin() Then ShellExecute("C:\TeamViewer\Teamviewer-x86.reg") WinWait("Registry Editor", "&Yes") WinActivate("Registry Editor", "&Yes") ControlClick("Registry Editor", "&Yes", 6) WinWait("Registry Editor", "OK") WinActivate("Registry Editor", "OK") ControlClick("Registry Editor", "OK", 2) Sleep(5000) EndIf ShellExecute("C:\TeamViewer\TurnOnTeamViewer.cmd") Link to comment Share on other sites More sharing options...
hiho Posted May 3, 2013 Share Posted May 3, 2013 (edited) Hi, why don't you use #RequireAdmin ? This way script won't be executed if the logged-on user doesn't have Admin rights. Edited May 3, 2013 by hiho Link to comment Share on other sites More sharing options...
CraigCustom Posted May 3, 2013 Author Share Posted May 3, 2013 It still pops up the window asking do you want to allows this program to run. The #RequireAdmin also not changing any colors it just looks like regular typing in the script. Link to comment Share on other sites More sharing options...
hiho Posted May 3, 2013 Share Posted May 3, 2013 (edited) Ok, try to test the "isadmin" function with something simple - If IsAdmin() Then MsgBox(0, "", "It's working") Else MsgBox(0, "", "It's not") EndIf Edited May 3, 2013 by hiho Link to comment Share on other sites More sharing options...
CraigCustom Posted May 3, 2013 Author Share Posted May 3, 2013 The account I'm on is an administrator account and its working. I gues my next problem is getting pass the UAC that pops up on the screen when I try running the script. Link to comment Share on other sites More sharing options...
hiho Posted May 3, 2013 Share Posted May 3, 2013 http://www.technorms.com/253/create-shortcuts-for-trusted-programs-to-bypass-windows-7-uac-check ? But.. it's a temporary fix... Link to comment Share on other sites More sharing options...
jdelaney Posted May 3, 2013 Share Posted May 3, 2013 How are you initiating the script? You can create a scheduled task, that runs at highest priviledge...that way, you just start the task, which get's around UAC (the legal way) IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
CraigCustom Posted May 3, 2013 Author Share Posted May 3, 2013 It says that it failed to lunch the script. Link to comment Share on other sites More sharing options...
User3D Posted May 6, 2013 Share Posted May 6, 2013 (edited) Hi, On my PC running Windows 7 64 bits; the script below works perfectly, and display the right message box depending on presence or absence of the clause #requireadmin: #requireadmin ; Administration rights check if IsAdmin()= 0 Then ; displayed only if requireadmin is not present MsgBox(0, "Ordinary user", "Administrator Rights not granted") Else ; displayed if requireadmin is present MsgBox(0, "Administrator", "Administrator Rights granted") EndIf Exit (0) The #requireadmin clause seems to be evaluated at the script lunch time and the windows asking to grant the administrator rights is opened and to grant the rights is accepted. If refused, the script is not launched. Thus, in script with the clause #requireadmin, the use of IsAdmin() is not relevant. I tried to make a script, which tests the administrator rights using IsAdmin(), and then if not granted asks for them. Obviously, the clause #requireadmin does not allow to create such script and the script below does not work as I’d like to: if IsAdmin()= 0 Then MsgBox(0, "Ordinary user", "Administrator Rights not granted") #requireadmin if IsAdmin()= 0 Then MsgBox(0, "After requireadmin", "Administrator Rights not granted") Else MsgBox(0, "After requireadmin", "Administrator Rights granted") EndIf Else MsgBox(0, "Administrator", "Administrator Rights granted") EndIf Exit (0) Do you have any idea by what the clause #requireadmin is to be replaced in order to get the correct message boxes? Brges User3D Edited May 6, 2013 by User3D LaOs 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now