RunAsCurrentUser Not working

(imported topic written by choro)

I’m trying to use RunAsCurrentUser v2.0 and having issues.

I do not receive any errors it just won’t execute the program (batch file).

This is my ActionScrip: (Have the download command downloading the util)

delete “c:\temp\Copy this file.resource”

copy “{(pathname of client folder of current site) & “__Download\Copy this file.resource”}” “c:\temp\Copy this file.resource”

delete “c:\temp\Copy this file.resource.xml”

copy “{(pathname of client folder of current site) & “__Download\Copy this file.resource.xml”}” “c:\temp\Copy this file.resource.xml”

delete __appendfile

appendfile @echo off

appendfile copy “c:\temp\Copy this file.resource” “c:\documents and settings%username%\My Documents\Software\Content\Copy this file.resource” /y

appendfile copy “c:\temp\Copy this file.resource.xml” “c:\documents and settings%username%\My Documents\Software\Content\Copy this file.resource.xml” /y

delete copyfile.bat

copy __appendfile copyfile.bat

wait “{(pathname of client folder of current site) & “__Download\RunAsCurrentUser-2.0.exe”}” --r “c:\temp\copyfile.bat”


I have verified that all files are copied where they should be. The .bat file is created and copied with no problems. I can double-click on the coped .bat file and it runs as needed.

Thank you for all your help.

(imported comment written by BenKus)

It seems like your copyfile.bat is in the wrong spot (I don’t see why it would be in “C:\temp”)…

Try changing the last line to:

wait “{(pathname of client folder of current site) & “__Download\RunAsCurrentUser-2.0.exe”}” --r copyfile.bat

Ben

(imported comment written by choro)

Hey Ben Kus, thank you for your reply.

The file is in the c:\temp directory because i copied it there from the __Download folder. I’ve check to make sure that the file is in c:\temp and it works fine if executed manually. But, won’t run when i pass it to the RunAsCurrentUser.

If I execute the RunAsCurrentUser thru a .bat file from my desktop should it execute the program as it would if I ran it thru a Fixlet?

Thanx

(imported comment written by BenKus)

Hey choro,

But in your actionscript you posted, I don’t see it copying to the “C:\temp” folder…

So basically it looks to me that you are telling RunAsCurrentUser.exe to run a file that doesn’t exist.

Ben

(imported comment written by SystemAdmin)

I’m guessing Choro is testing a manually copied a copyfile.bat to c:\temp and kicked off the action. So the action creates a file that’s not used and rather uses a file that’s present.

His last question asks if he can try using RunAsCurrentUser.exe in his own personal .bat file to see if it works (without using BigFix at all). I guess you could as long as you launch it as the system account? I don’t know if you can run that as just a local admin. If so, (and it’s Vista), you’ll have to at least run it as administrator.

Choro – I’m guessing your problem might be that your not downloading RunAsCurrentUser-2.0.exe at all. Try adding the following to the beginning of your action. Also change your line that run RunAsCurrentUser-2.0.exe and make it just RunAsCurrentUser.exe.

if {exists current user}

prefetch RunAsCurrentUser.exe sha1:5512ef51a98dff1aa910a8189a0361c161fa703f size:212992 http://software.bigfix.com/download/bes/util/RunAsCurrentUser-2.0.2.exe

utility __Download\RunAsCurrentUser.exe

…But yes, after all your testing… in the end you should have it run copyfile.bat and not c:\temp\copyfile.bat. I think you realize that already.

-Paul

(imported comment written by gjeremia91)

I had many issues with run as current user - especially if my batch file uses STDIN or STDOUT, so make sure that your script is “quiet”.

so, try:

delete __appendfile

appendfile @echo off

appendfile copy “c:\temp\Copy this file.resource” “c:\documents and settings%username%\My Documents\Software\Content\Copy this file.resource” /y >NUL 2>&!

appendfile copy “c:\temp\Copy this file.resource.xml” “c:\documents and settings%username%\My Documents\Software\Content\Copy this file.resource.xml” /y >NUL 2>&!

delete copyfile.bat

copy __appendfile copyfile.bat

wait “{(pathname of client folder of current site) & “__Download\RunAsCurrentUser-2.0.exe”}” --w “{(pathname of client folder of current site)}\copyfile.bat”