Jump to content

Test user/password in _ShellExecuteWaitAsAdmin


Docfxit
 Share

Recommended Posts

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

Link to comment
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

 

Link to comment
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

 

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
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?

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...