Jump to content

RunAs Adminstrator not working


Recommended Posts

 

So I created this script, but when running it nothing happens.

what did I do wrong?

This my script:

#include <AutoItConstants.au3>

vms()

Func vms()
    ; Change the username and password to the appropriate values for your system.
    Local $sUserName = "user"
    Local $sPassword = "password"


    Local $iPID = RunAs($sUserName, @ComputerName, $sPassword, $RUN_LOGON_PROFILE,"C:\Program Files\iVMS-4200 Station\iVMS-4200\iVMS-4200 Client\iVMS-4200.exe"," ", @SW_SHOWMAXIMIZED)


EndFunc   ;==>vms

Link to post
Share on other sites

Hi @galvatec, and welcome to the AutoIt forums :welcome:

Did you check the following in the Help file?

Quote

Remarks

Paths with spaces need to be enclosed in quotation marks.

It is important to specify a working directory the user you are running as has access to, otherwise the function will fail.

Try to enclose your file path in quotation marks, and try it again :)

P.S.: Use the standard font and use the <> Code Tag to post some code in your thread; that will make the post more readable :)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to post
Share on other sites
  • Developers

Guess this needs to run in x64 mode...so are you doing that?

What is the returncode and @error from the run?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

Many thanks for the reply.

@FrancescoDiMuro I wasn't sure about the quotes on the way with spaces, so I redid the way it is in the code below, please let me know if this is correct as it hasn't worked yet. I set the working directory using the directory we use here in the company that is 😄 \ Support is it correct to put the work directory in this way in the code?
Regarding the source for posting the code I used the AutoIT font because I copied the text there, can you change the font?
Please forgive me my ignorance I am new to the forum and AutoIT.


@Jos Regarding running on x64 I don't know how to do that, could you show me?


       Local $ IPID = RunAs ($ sUserName, @ComputerName, $ sPassword, $ RUN_LOGON_PROFILE, "C: \ Program" "Files \ iVMS-4200" "Estação \ iVMS-4200 \ iVMS-4200" "Client \ iVMS-4200. exe "," 😄 \ Suporte ", @SW_SHOWMAXIMIZED)

>

Link to post
Share on other sites
  • Developers
28 minutes ago, galvatec said:

I don't know how to do that, could you show me?

Did you check the helpfile? ...guess not!  :)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
  • Developers

No idea what you are telling me:  Your question was about x64 and now you talk about Working directory?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
I am confused because this script works, even without changing as x64 settings

<     
#include <AutoItConstants.au3>
  
RunAs("alfreire", @ComputerName, "28437620", $RUN_LOGON_PROFILE,'"C:\Program Files (x86)\teraterm\ttermpro.exe"',"",     @SW_SHOWMAXIMIZED)
>

 

However this script does not work and not the error message.

<
#include <AutoItConstants.au3>

 RunAs("alfreire", @ComputerName, "28437620", $RUN_LOGON_PROFILE,'"C:\Program Files (x86)\iVMS-4200 Station\iVMS-4200\iVMS-4200 Client\iVMS-4200.exe"',"", @SW_SHOWMAXIMIZED)

>

Link to post
Share on other sites

Estou confuso porque esse script funciona, mesmo sem alterar as configurações do x64


<

#include <AutoItConstants.au3>
RunAs ("alférire", @Nome_do_Computador, "28437620", $ RUN_LOGON_PROFILE, '"C: \ Arquivos de Programas (x86) \ teraterm \ ttermpro.exe"', "", @SW_SHOWMAXIMIZED)

>

No entanto, este script não funciona e não a mensagem de erro.

<
#include <AutoItConstants.au3>

 RunAs ("alférire", @Nome do Computador, "28437620", $ RUN_LOGON_PROFILE, '"C: \ Arquivos de Programas (x86) \ iVMS-4200 Estação \ iVMS-4200 \ iVMS-4200 Client \ iVMS -4200.exe "'," ", @SW_SHOWMAXIMIZED)

>

Link to post
Share on other sites
  • Developers

Please stick to one thread and one version of the script !

Merged and let this be the last intervention as I get tired of having to clean up stuff.

Jos

 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
  • Developers

We don't t remove topics. Just bring it back on track, as you derailed it, by asking what it is you really want to know.

Jos

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

 

I'm confused because this script works even without changing x64 settings

<

#include <AutoItConstants.au3>   

RunAs ("alfreire", @ComputerName, "28437620", $ RUN_LOGON_PROFILE, "" 😄 \ Program Files (x86) \ teraterm \ ttermpro.exe "'," "@SW_SHOWMAXIMIZED) >  

However, this script does not work and not the error message.

<

#include <AutoItConstants.au3>  RunAs ("alfireire", @Computer Name, "28437620", $ RUN_LOGON_PROFILE, '"C: \ Program Files (x86) \ iVMS-4200 Station \ iVMS-4200 \ iVMS-4200 Client \ iVMS -4200.exe" ', "" @SW_SHOWMAXIMIZED)

>

 

I need to know why the second script doesn't work, it conforms to what is shown in the help file and doesn't work.

Link to post
Share on other sites
  • Developers
23 minutes ago, galvatec said:
#include <AutoItConstants.au3>  
RunAs ("alfireire", @Computer Name, "28437620", $ RUN_LOGON_PROFILE, '"C: \ Program Files (x86) \ iVMS-4200 Station \ iVMS-4200 \ iVMS-4200 Client \ iVMS -4200.exe" ', "" @SW_SHOWMAXIMIZED)

 

This will never work as it contains a syntax error and it has spaces all over the place, so what is the exact fully qualified path+filename for the exe?

Something like this should be closer to what you need, but update the path so it is correct:

#include <AutoItConstants.au3>  
RunAs ("alfireire", @ComputerName, "28437620", $ RUN_LOGON_PROFILE, "C:\Program Files (x86)\iVMS-4200 Station\iVMS-4200\iVMS-4200 Client\iVMS-4200.exe", "C:\Program Files (x86)\iVMS-4200 Station\iVMS-4200\iVMS-4200 Client", @SW_SHOWMAXIMIZED)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
  • Developers

Just answer my question:

15 minutes ago, Jos said:

so what is the exact fully qualified path+filename for the exe?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...