Jac Posted September 25, 2007 Share Posted September 25, 2007 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 Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 25, 2007 Share Posted September 25, 2007 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 Link to comment Share on other sites More sharing options...
Jac Posted September 25, 2007 Author Share Posted September 25, 2007 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 Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 25, 2007 Share Posted September 25, 2007 It ask me but when it execute the command belowRunWait(@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 Link to comment Share on other sites More sharing options...
Developers Jos Posted September 25, 2007 Developers Share Posted September 25, 2007 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... 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 comment Share on other sites More sharing options...
Jac Posted September 26, 2007 Author Share Posted September 26, 2007 [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) Link to comment Share on other sites More sharing options...
Developers Jos Posted September 26, 2007 Developers Share Posted September 26, 2007 [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 ... 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 comment Share on other sites More sharing options...
PsaltyDS Posted September 26, 2007 Share Posted September 26, 2007 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 Link to comment Share on other sites More sharing options...
Jac Posted September 26, 2007 Author Share Posted September 26, 2007 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 ? Link to comment Share on other sites More sharing options...
Developers Jos Posted September 26, 2007 Developers Share Posted September 26, 2007 (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 September 26, 2007 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 comment Share on other sites More sharing options...
Jac Posted September 26, 2007 Author Share Posted September 26, 2007 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 modeI 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 whyAnyway thanks all for your help Link to comment Share on other sites More sharing options...
Jac Posted September 26, 2007 Author Share Posted September 26, 2007 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 ! Link to comment Share on other sites More sharing options...
Developers Jos Posted September 26, 2007 Developers Share Posted September 26, 2007 yes i tried that in admin mode it work but not in user modeI 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 whyAnyway thanks all for your helpThe 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().. 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 comment Share on other sites More sharing options...
Jac Posted September 26, 2007 Author Share Posted September 26, 2007 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 ! 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