KSum Posted March 1, 2012 Share Posted March 1, 2012 It appears that RunAs will run, but not as the administrator. A script comprised only of the below code does not allow Install_IDRs.exe to copy files to locations where the local computer's administrator account has access manually. If I run this under the local administrator's log-in it works, suggesting the executable is run with the logged in credentials and not the admonistrator's. Any idea what I may have wrong here? $copyFileLocation = @ScriptDir & "\Support\" $copyFileFullName = $copyFileLocation & "Install_IDRs.exe" Local $sUserName = "administrator" Local $sPassword = "mywrongpassword" $Status = RunAs($sUserName, @ComputerName, $sPassword, 2, $copyFileFullName, @DesktopDir) MsgBox(4096, "IDR Installation", $Status) Install_IDRs.exe is a script which I Built using the Build option in the SciTE editor. It uses FileCopy to copy a file from one location to another. In my test cases it is from a folder on teh local hard drive to another folder on the local hard drive Karl Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted March 1, 2012 Moderators Share Posted March 1, 2012 (edited) Hi, KSum. To start, try changing this: $copyFileFullName = $copyFileLocation & "Install_IDRs.exe" to this: $copyFileFullName = $copyFileLocation & "Install_IDRs.exe" I ran it like this, using a different compiled script, and it worked just fine using admin creds. Edited March 1, 2012 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
KSum Posted March 1, 2012 Author Share Posted March 1, 2012 JLogan3o13,Thank you for the response. That effectively made the $copyFileFullName equal c:tempSupportInstall_IDRs.exe and didn't seem to help. It still ran Install_IDRs.exe but apparently not with the correct permissions.Karl Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted March 1, 2012 Moderators Share Posted March 1, 2012 I'm assuming you're doing this on XP, is that correct? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
KSum Posted March 1, 2012 Author Share Posted March 1, 2012 Windows 7 is the test machine. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted March 1, 2012 Moderators Share Posted March 1, 2012 Hmm.. that complicates it. Someone much more intelligent than I can probably weigh in, but I believe in Windows 7 your ONLY option is #RequireAdmin "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
MrAutomationGuy Posted March 1, 2012 Share Posted March 1, 2012 Is that a local administrator or domain? Try using this format for your username: "<domainName><userName>". Link to comment Share on other sites More sharing options...
KSum Posted March 2, 2012 Author Share Posted March 2, 2012 That was local. I had thought about adding the domain name but since it is already passed to RunAs I opted against. Regardless, I made the change as shown below and that didn't help. Local $sUserName = @ComputerName & "\administrator" Local $sPassword = "mywrongpassword" ; Run a command prompt as the other user. $Status = RunAs($sUserName, @ComputerName, $sPassword, 2, $copyFileFullName, @DesktopDir) So then I tried removing @ComputerName, to make the Run As look like this, but that didn't let $copyFileFullName run at all: ; Run a command prompt as the other user. $Status = RunAs($sUserName, "", $sPassword, 2, $copyFileFullName, @DesktopDir) NOTE: The password I am using is actually the correct password, and the Secondary Logon (RunAs) service is enabled. When I change the password to a bad password, $copyFileFullName does not run. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted March 3, 2012 Share Posted March 3, 2012 Do you have UAC on? Then I believe you should use ShellExecute() with the runas verb to launch as admin. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface 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