Jump to content
Sign in to follow this  
MattX

RunAsSet Problem

Recommended Posts

MattX

Not sure why this is not working - I have gone through quite alot of threads about the RunAsSet command and I'm still stuck.

The error message I'm getting is 'Unable to execute the external program. The Directory is invalid'

Which is odd because if I ; out the RunAsSet command it runs fine but of couse without the rights. It needs admin rights because the killProcess.exe is a prog that kills processes better than than windows task manager.

I have tried this [ as you can see ] as a local account, also as part of the domain too but still no luck - would appreciate some advice.

$sPass = 'killapp'
Do
   $sInput = InputBox( "Password Prog", "Insert password to continue" & @LF & "The password is Case Sensitive.", "", ".")
   If @error Then Exit
   If $sPass == $sInput Then ExitLoop
   MsgBox(4096 + 16, 'Error!', 'Password wrong.' & @LF & 'Try again.')
Until 0
RunAsSet("administrator", @ComputerName, "PASSWORD")
Run("C:\KillProcess\KillProcess.exe")
RunAsSet()

Share this post


Link to post
Share on other sites
Doxie

Then you are using wrong password/username.

Or wrong path to the exe file.

I copied pasted your code, and it runs nice on my computer.

$sPass = 'killapp'
Do
  $sInput = InputBox( "Password Prog", "Insert password to continue" & @LF & "The password is Case 

Sensitive.", "", ".")
  If @error Then Exit
  If $sPass == $sInput Then ExitLoop
  MsgBox(4096 + 16, 'Error!', 'Password wrong.' & @LF & 'Try again.')
Until 0
RunAsSet("user", @LogonDomain, "pass")
Run("notepad.exe")
RunAsSet()

Edit: Copy/paste my code above, but change to your login.

Edit2: You can also try to use RunWait instead of Run

Edit3: Maybe you need to use the program with a command? For example wich process you wanna kill.

Edited by Doxie

Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites
SumTingWong

$sPass = 'killapp'
Do
   $sInput = InputBox( "Password Prog", "Insert password to continue" & @LF & "The password is Case Sensitive.", "", ".")
   If @error Then Exit
   If $sPass == $sInput Then ExitLoop
   MsgBox(4096 + 16, 'Error!', 'Password wrong.' & @LF & 'Try again.')
Until 0
RunAsSet("administrator", @ComputerName, "PASSWORD")
Run("C:\KillProcess\KillProcess.exe", "C:\KillProcess")
RunAsSet()

I normally get that same error message when I try to launch the exe from a network location which of course is not available under the admin user context.

Edited by pacman

Share this post


Link to post
Share on other sites
MattX

This is very odd, I even tried just lauching notepad but still the same problem.

I have checked and the secondary logon service is also running and the passwords and logons are ok....

Tried RunWait but the same issue, also the app is a GUI so gives you list of running processes - It launches fine without the RunAsSet - which of course I don't want to do !!

Then you are using wrong password/username.

Or wrong path to the exe file.

I copied pasted your code, and it runs nice on my computer.

$sPass = 'killapp'
Do
  $sInput = InputBox( "Password Prog", "Insert password to continue" & @LF & "The password is Case 

Sensitive.", "", ".")
  If @error Then Exit
  If $sPass == $sInput Then ExitLoop
  MsgBox(4096 + 16, 'Error!', 'Password wrong.' & @LF & 'Try again.')
Until 0
RunAsSet("user", @LogonDomain, "pass")
Run("notepad.exe")
RunAsSet()

Edit: Copy/paste my code above, but change to your login.

Edit2: You can also try to use RunWait instead of Run

Edit3: Maybe you need to use the program with a command? For example wich process you wanna kill.

<{POST_SNAPBACK}>

Edited by MattX

Share this post


Link to post
Share on other sites
Doxie

Try this code:

; Set the RunAs parameters to use local adminstrator account
RunAsSet("admin", @Computername, "adminpassword")
$var=AutoItSetOption ( "RunErrorsFatal", 0 )
; Check if admin is ok
    If $var = 1 Then
        MsgBox(0, "Error", "Account is not ok.")
    Exit
EndIf


; Run notepad as admin
RunWait("Notepad.exe","",@SW_MINIMIZE)
Sleep(2000)
WinClose("Untitled - Notepad", "") 

; Reset user's permissions
RunAsSet()

Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites
SumTingWong

Hi,

The error you are getting

The error message I'm getting is 'Unable to execute the external program. The Directory is invalid'

is probably caused by an invalid working dir in your run command.

You need to specify a valid working dir when using run under the admin user context.

e.g

Run("C:\KillProcess\KillProcess.exe", "C:\KillProcess")

or

Run("C:\KillProcess\KillProcess.exe", @SystemDir)

and so on....

Share this post


Link to post
Share on other sites
MattX

Thanks Pacman - worked with the valid working dir - apprecaite all help given people - many thanks.

Hi,

The error you are getting

is probably caused by an invalid working dir in your run command.

You need to specify a valid working dir when using run under the admin user context.

e.g

Run("C:\KillProcess\KillProcess.exe", "C:\KillProcess")

or

Run("C:\KillProcess\KillProcess.exe", @SystemDir)

and so on....

<{POST_SNAPBACK}>

Share this post


Link to post
Share on other sites
Doxie

Is this the same problem?

RunAsSet("user", @ComputerName, "password")
RunWait(@ComSpec & " /c " & 'copy c:\test.txt c:\test\test.txt', "", @SW_HIDE)
RunAsSet()

Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites
Doxie

This is the file i try to copy:

\\xp2app02\win2000\apps\Level_B\2KSAV81\GRC.DAT

To this location:

C:\Documents and Settings\All Users\Application Data\Symantec\Norton AntiVirus Corporate Edition\7.5\GRC.DAT

And since user is not admins, they can´t do that. So i thought running RunAsSet would solve it. But i can´t get it to work. Help :idiot:

EDIT:

I read that i can of course not use the Computer admin, since then it will not be able to access the network. So my idea is to copy a script down to the computer and then run it. But i can´t get the FileCopy or the Copy to work.

Anyone?

Edited by Doxie

Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites
Jos

This is the file i try to copy:

\\xp2app02\win2000\apps\Level_B\2KSAV81\GRC.DAT

To this location:

C:\Documents and Settings\All Users\Application Data\Symantec\Norton AntiVirus Corporate Edition\7.5\GRC.DAT

And since user is not admins, they can´t do that. So i thought running RunAsSet would solve it. But i can´t get it to work. Help :idiot:

<{POST_SNAPBACK}>

You probably will loose the access to \\xp2app02\win2000\apps\Level_B\2KSAV81\GRC.DAT after you do RunAsSet()

You could first copy it to @tempDir, then do the RunAsSet and Filecopy it to the Symantec directory.


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

Share this post


Link to post
Share on other sites
Doxie

I tried that... but its not working?

RunWait(FileCopy("\\xp2app02\win2000\apps\Level_B\2KSAV81\GRC.DAT", @TempDir), "", @SW_HIDE)

I get the message that it can't be located.

EDIT:

Its not even working if i change to:

RunWait(FileCopy("c:\GRC.DAT", @TempDir), "", @SW_HIDE)

Edited by Doxie

Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites
Jos

I tried that... but its not working?

RunWait(FileCopy("\\xp2app02\win2000\apps\Level_B\2KSAV81\GRC.DAT", @TempDir), "", @SW_HIDE)

I get the message that it can't be located.

<{POST_SNAPBACK}>

Try:

FileCopy("\\xp2app02\win2000\apps\Level_B\2KSAV81\GRC.DAT", @TempDir ,1)


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

Share this post


Link to post
Share on other sites
Doxie

aah i should not use RunWait on FileCopy :idiot:

hehe


Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites
Doxie

Its still not working?

FileCopy("\\xp2app02\win2000\apps\Level_B\2KSAV81\GRC.DAT", @TempDir ,1)

RunAsSet("user", @ComputerName, "pass")
FileCopy(@TempDir & "\GRC.DAT", "C:\Documents and Settings\All Users\Application Data\Symantec\Norton AntiVirus Corporate Edition\7.5\GRC1.DAT")
RunAsSet()

The code seems to work, but still i can't copy it, i belive its a access problem.

Can't i use RunAsSet with FileCopy?

Edited by Doxie

Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites
Doxie

Error: String missing closing quote

RunWait('"' & @SCRIPTFULLPATH & '" /ImAdmin")

RunWait('"' & @SCRIPTFULLPATH & '" /ImAdmin^ËRROR

Sorry for just copy/paste, but i'm tired and have a hard time see even the most simple problems

Edited by Doxie

Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites
Doxie

Sorry to bug you again Larry, but....

Still got the original error message:

RunWait('"' & @SCRIPTFULLPATH & '" /ImAdmin')

Error: Unable to execute the external program.


Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites
Jos

Sorry to bug you again Larry, but....

Still got the original error message:

RunWait('"' & @SCRIPTFULLPATH & '" /ImAdmin')

Error: Unable to execute the external program.

<{POST_SNAPBACK}>

did you compile it first and that run the script.exe ?? :idiot:

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

Share this post


Link to post
Share on other sites
Doxie

did you compile it first and that run the script.exe ?? :D

<{POST_SNAPBACK}>

No, i never compiled it.. I will test it after lunch :idiot:

Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites
motzel

Hello,

i have checked the problem again and again, and now i can say, that it happend when you have: windows XP Sp2 + runasset + a network drive :D

e.g. the code for a script with the name a.exe

RunAsSet("administrator", "domainname", "password")

RunWait("h:\public\b.exe", "h:\public\")

Exit

a.exe is on the shared drive h:\public\a.exe

and should only call the file h:\public\b.exe

When i don't use RunAsSet it works fine,

when the file a.exe and b.exe are on the local drive e.h. C:\ it works fine,

but when a.exe and b.exe are on the network drive i get the error message:

Error: Unable to execute the external program :lol:

Please can anybody give me a tip :idiot:

motzel

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  

×