Sign in to follow this  
Followers 0
Docfxit

Test user/password in _ShellExecuteWaitAsAdmin

11 posts in this topic

I know the python script is running.  Is there a way to test the userdomain and userpassword to make sure there isn't a permissions issue in the python script.

My AutoIt script is:

#RequireAdmin
;_ShellExecuteWaitAsAdmin("userlogin","userdomain", "userpassword", 0, "\\server\path_to_batch\batch.bat")

_ShellExecuteWaitAsAdmin("Administrator", "workgroup", "MyPassword", 0, "C:\Batch\CGPLog.bat")

Func _ShellExecuteWaitAsAdmin($sUserName, $sDomain, $sPassword, $iLogonFlag, $sFile, $sParamters = "")
    Local $sCmd = ' /AutoIt3ExecuteLine "ShellExecuteWait(''' & $sFile & ''', ''' & $sParamters & ''', '''', ''runas'')"'
    Return RunAsWait($sUserName, $sDomain, $sPassword, $iLogonFlag, @AutoItExe & $sCmd)
EndFunc   ;==>_ShellExecuteWaitAsAdmin

The bat file I'm trying to run:

cd "C:\Programs\CommuniGate Files\SystemLogs"
Call "C:\Batch\CGPLogSummary.py" 
cmd

The python script isn't reading/writing the files it should.  I'm not getting any errors.

Thanks,

Docfxit

Share this post


Link to post
Share on other sites



What happens when you try to run the commands manually without autoit?


Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites

I right click on the bat file and select run as administrator.

I get Access is denied.

Thanks,

Docfxit

Share this post


Link to post
Share on other sites

Are you using an administrator account?


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

Yes.  The user I am signed on with does have administrator rights.

Thanks,

Docfxit

Share this post


Link to post
Share on other sites

Hmph. So even on your admin account you cannot access it manually or with AutoIt?


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Your alignment looks a bit off, may not be, but looks it to me.

Try replacing your $sCmd and RunWait with this:

Local $sCmd = '"' & @AutoItExe & '" /AutoIt3ExecuteLine "ShellExecuteWait("""' & $sFile & '""", """' & $sParamters & '""", "", "runas")"'
Return RunAsWait($sUserName, $sDomain, $sPassword, $iLogonFlag, $sCmd)

Edit:

BTW, you do have an app on the machine you're trying to run this on by the same name right?  If you're sending this via F5 it uses the AutoIt exe in the AutoIt directory, if you're compiling and sending it, it's using the name and location of the exe you're compiling.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Thank you for the suggestion.

I'm getting an error saying:

AutoItError.png

Docfxit

Share this post


Link to post
Share on other sites

Although the new AutoIt code is causing a problem.  I tried running the bat file while logged in as Administrator.  So I think it's a problem with the python script and maybe not the authorization it's running under.

I would like to correct the AutoIt code so that when I get the python script running correctly I will be able to run this under the correct user.

Thanks,

Docfxit

PS:  Does anyone know where I can get help with the python script?

Share this post


Link to post
Share on other sites

Starting to confuse myself with this.  I don't use this function, but I know you need to concatenate the quotes in case of spaces.

Also the fourth parameter is a verb, I don't see "runas" as an acceptable verb.

 
Try this I guess:
Local $sCmd = '"' & @AutoItExe & '" /AutoIt3ExecuteLine ' & '"ShellExecuteWait(""' & $sFile & '"", ""' & $sParamters & '"", "", Null)"'

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

That does run without giving me errors.

I will know more when I get the Python script executing correctly.

Thank you very much,

Docfxit

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