toofat Posted April 13, 2008 Share Posted April 13, 2008 This Script works like a charm: RunAsSet ("ADMINISTRATOR", @Computername, "ADMINPASS", 0) Run ("Notepad.exe") This one doesn't: RunAsSet ("REGULARUSER", @Computername, "USERPASS", 0) Run ("Notepad.exe") "Regular User" has loged on to "@Computername" ... When I'm loged on as admin and run Windows RunAs as "Regular User" on Notepad it works OK but when I run Notepad from AutoIt (as "Regular User") it displays "Error: Unable to execute the external program. The directory name is invalid." Link to comment Share on other sites More sharing options...
rudi Posted April 14, 2008 Share Posted April 14, 2008 Hi.RunAsSet() can enter the security context of any user.What results does this code give to you?run ("net user foo bar /add") RunAsSet("foo",@ComputerName,"bar",0) RunWait (@ComSpec & " /k set") MsgBox(0,"","done")Maybe it's a NTFS rights issue for the user you want to use?Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Developers Jos Posted April 14, 2008 Developers Share Posted April 14, 2008 Try adding a Workdir to the Run() statement that is accessible for the "REGULARUSER". 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...
toofat Posted April 14, 2008 Author Share Posted April 14, 2008 Hi. RunAsSet() can enter the security context of any user. What results does this code give to you? run ("net user foo bar /add") RunAsSet("foo",@ComputerName,"bar",0) RunWait (@ComSpec & " /k set") MsgBox(0,"","done") Maybe it's a NTFS rights issue for the user you want to use? Regards, Rudi. Well no change Rudi, returns the same error and it doesn't return error when user has admin rights ... and it's not a problem with directory access rights or @WorkingDir (I have tried all of the combinations and all produce the same error) because I try to run "Notepad" which even guest account can run (and REGULARUSER is just that; "Regular User" and not a guest) ... I have AutoIt ver 3.2.10.0 installed ... which ver do you have ??? Link to comment Share on other sites More sharing options...
toofat Posted April 14, 2008 Author Share Posted April 14, 2008 Try adding a Workdir to the Run() statement that is accessible for the "REGULARUSER". OK, I'm an idiot. What I've tried to do is Run ("C:\WINDOWS\NOTEPAD.EXE") and what I should have done is Run ("NOTEPAD.EXE", "C:\WINDOWS") OK, now it works and I am idiot ... Thanks for help ... Link to comment Share on other sites More sharing options...
Developers Jos Posted April 14, 2008 Developers Share Posted April 14, 2008 OK, I'm an idiot. What I've tried to do is Run ("C:\WINDOWS\NOTEPAD.EXE") and what I should have done is Run ("NOTEPAD.EXE", "C:\WINDOWS") OK, now it works and I am idiot ... Thanks for help ...Nah, you are not a complete idiot It is common to supply the full path in the first parameter. The real issue you have is that the current workdir is only accessible by the Original User, not the RunAs user, which makes the Run() command fail. In your case it fixed the issue because Windows knows to find notepad, but for any other program it would still fail. eg: Run ("C:\program files\myapp.EXE", "C:\WINDOWS") 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...
toofat Posted April 14, 2008 Author Share Posted April 14, 2008 Nah, you are not a complete idiot It is common to supply the full path in the first parameter. The real issue you have is that the current workdir is only accessible by the Original User, not the RunAs user, which makes the Run() command fail. In your case it fixed the issue because Windows knows to find notepad, but for any other program it would still fail. eg: Run ("C:\program files\myapp.EXE", "C:\WINDOWS") Jos OK Jos I understand that this won't work Run ("C:\program files\myapp.EXE", "C:\WINDOWS") Trust me when I say that I understand that if User1 tries to access dir that only User2 has access to he will not succed, through Windows, through RunAs (loged on as User2 or admin but RunAsSet is configured for User1) or even through Black Magic :-)) ... But can you explain to me why for admin this works RunAsSet ("ADMINISTRATOR", @Computername, "ADMINPASS", 0) Run ("Notepad.exe") and for regular user it must be written like this RunAsSet ("REGULARUSER", @Computername, "USERPASS", 0) Run ("Notepad.exe", "C:\WINDOWS") I will say one more time that Regular User has access to "C:\WINDOWS" (full read access just not admin rights), that he has allready loged on and ... Why for admin you don't have to specify WorkingDir and for Regular user you do ??? Thanks for help and I would apriciate the answer and sorry for bad speling ... Link to comment Share on other sites More sharing options...
Developers Jos Posted April 14, 2008 Developers Share Posted April 14, 2008 (edited) From which directory are you starting this script and does the REGULARUSER have access to this script directory ? Jos Edited April 14, 2008 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...
toofat Posted April 14, 2008 Author Share Posted April 14, 2008 From which directory are you starting this script and does the REGULARUSER have access to this script directory ?JosOK now I see what you are getting at . Yes, REGULARUSER does not have access to the script dir. I execute the script like admin but ... OK, I understand. When I get home I will try to execute it from some dir that REGULARUSER has access to. Thank you very much ... The solution is so logical and so clear to me now. Like I've sad before; I'm an idiot. NTFS basics. Yes, yes, I'm an idiot. 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