Sign in to follow this  
Followers 0
Jac

RunAsSet help please

14 posts in this topic

Im trying to use this command with non-admin users but it don't seem to work.

$returnvalue return me 1

If Not IsAdmin() Then

$returnvalue = RunAsSet("autoit","nomdudomaine","password")

msgbox(0,"info",$returnvalue

EndIf

RunWait(@ComSpec & " /c " & "xcopy """ & @scriptdir & "\EN\Default User"" ""C:\Documents and Settings\Default User"" /h /i /c /k /e /r /y","c:\windows\system32",@SW_HIDE)

Should it work or not ?

If i run this script with my admin user it work

Thanks for helping me

Jac

Share this post


Link to post
Share on other sites



Test your given credentials with this demo, adapted from the one in the help file under RunAsSet():

If IsAdmin() Then
    MsgBox(64, 'Message', 'Now running with admin rights.')
Else
    If MsgBox(16 + 4, "Not Admin", "Not running as admin: attempt RunAsSet?") = 6 Then
        RunAsSet("autoit", "nomdudomaine", "password")
        Run('"' & @AutoItExe & '"' & ' "' & @ScriptFullPath & '"', @WorkingDir)
    EndIf
EndIf

If you run it as a non-admin, it should prompt you Yes/No to attempt the RunAsSet.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

It ask me but when it execute the command below

RunWait(@ComSpec & " /c " & "xcopy """ & @scriptdir & "\EN\Default User"" ""C:\Documents and Settings\Default User"" /h /i /c /k /e /r /y","c:\windows\system32",@SW_HIDE)

There is nothing that is going on. No copy :)

Share this post


Link to post
Share on other sites

It ask me but when it execute the command below

RunWait(@ComSpec & " /c " & "xcopy """ & @scriptdir & "\EN\Default User"" ""C:\Documents and Settings\Default User"" /h /i /c /k /e /r /y","c:\windows\system32",@SW_HIDE)

There is nothing that is going on. No copy :)

You misunderstand the test, or you are just not telling me how it came out: Run the code I posted without changing the Run() line. Do not insert your xcopy command. Only edit the user/domain/password to actual values and run it.

It should prompt you once to attempt the RunAsSet, and then run itself again popping a message that is now running as an admin. That's all we want to know for now -- that your credentials are working.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

also when testing you could change the line to the below and see if there is an error:

RunWait(@ComSpec & " /k xcopy """ & @scriptdir & "\EN\Default User"" ""C:\Documents and Settings\Default User"" /h /i /c /k /e /r /y","c:\windows\system32")

This will leave the CMD window open and show it to see if there are any errors...


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

Share this post


Link to post
Share on other sites

[Jos]

ok i ran the command like you ask: (thanks for that tip "/k")

RunWait(@ComSpec & " /k xcopy """ & @scriptdir & "\EN\Default User"" ""C:\Documents and Settings\Default User"" /h /i /c /k /e /r /y","c:\windows\system32")

and here is my error:

The system cannot find the path specified.

C:\WINDOWS\system32>

[PsaltyDS]

Ok i tried what u ask, first it ask pop me that im not running in admin mode so i click yes

But i get this error (i join a screenshot)

post-24188-1190813736_thumb.jpg

Share this post


Link to post
Share on other sites

[Jos]

ok i ran the command like you ask: (thanks for that tip "/k")

RunWait(@ComSpec & " /k xcopy """ & @scriptdir & "\EN\Default User"" ""C:\Documents and Settings\Default User"" /h /i /c /k /e /r /y","c:\windows\system32")

and here is my error:

The system cannot find the path specified.

C:\WINDOWS\system32>

Well then you should try to run the xcopy command manually in this generated CMD window and see if that works ...

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

Share this post


Link to post
Share on other sites

As Jos pointed out, there is something wrong with your command line. The code I gave you in post #2 above works fine for me on XP Pro SP2.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Well then you should try to run the xcopy command manually in this generated CMD window and see if that works ...

Well the same exact command work with an admin user :)

So i dont think it's a problem with the command ?

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Well the same exact command work with an admin user :)

So i dont think it's a problem with the command ?

The question is if the Xcopy command works in the CMD window opened by the Script when done manually?

Did you try that ?

Edited by Jos

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

Share this post


Link to post
Share on other sites

The question is if the Xcopy command works in the CMD window opened by the Script when done manually?

Did you try that ?

yes i tried that in admin mode it work but not in user mode

I found that it work if i put the UNC path

"xcopy ""\\bldfile\Services\Publique\TI\Default User Template\XP\EN\Default User"" ""C:\Documents and Settings\Default User"" /h /i /c /k /e /r /y"

instead of using

"xcopy """"" & @scriptdir & "\EN\Default User"" ""C:\Documents and Settings\Default User"""" /h /i /c /k /e /r /y"

Dont know why

Anyway thanks all for your help

Share this post


Link to post
Share on other sites

Guys do you know if we can use UNC path with the variable @workingdir

instead of returning me the value

M:\TECHNOLOGIES INFORMATIONS\Courant\Logiciels\AutoIT\Programmes\Default User Template

it would return me

\\bldfile\Services\TECHNOLOGIES INFORMATIONS\Courant\Logiciels\AutoIT\Programmes\Default User Template

Thanks again for your help !

Share this post


Link to post
Share on other sites

yes i tried that in admin mode it work but not in user mode

I found that it work if i put the UNC path

"xcopy ""\\bldfile\Services\Publique\TI\Default User Template\XP\EN\Default User"" ""C:\Documents and Settings\Default User"" /h /i /c /k /e /r /y"

instead of using

"xcopy """"" & @scriptdir & "\EN\Default User"" ""C:\Documents and Settings\Default User"""" /h /i /c /k /e /r /y"

Dont know why

Anyway thanks all for your help

The mapped drives will not be available when you change credentials with RunAsSet().

UNC paths should work fine ...

@workingDir UNC question:You can retrieve the UNC connected with the Mapped drive by using DriveMapGet()..


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

Share this post


Link to post
Share on other sites

The mapped drives will not be available when you change credentials with RunAsSet().

UNC paths should work fine ...

@workingDir UNC question:You can retrieve the UNC connected with the Mapped drive by using DriveMapGet()..

Thanks !

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