Jump to content

FileCopy not working when using runas


Recommended Posts

Hi,

I have written a scan utility that scans for certain items on the machine and upload the report to shared path

The utility consists of 2 exe files

1) Scanner.exe: Scanner.exe will be running under local admin credentials. This exe does the following functions 1)Scans the machine 2)Write the report in 'C:report.txt' 3)Executes fileuploader.exe with runas function (using credentials which have access to shared path)

2) Fileuploader.exe: Copy 'C:report.txt' to shared path

When I execute scanner.exe, the report gets generated, but not getting copied to the shared path.

The same happens when I manually do a runas for Fileuploader.exe

But when I run Fileuploader by double clicking on Fileuploader.exe, the file is copied to the shared path

Attached are the codes for both exe files

Any tips would be of great help

Thanks in advance

Roshith

;
;
;
;Code for Scan
$sReport = "Scan is completed"
$hFile = FileOpen("C:" & @ComputerName & ".txt", 2)
FileWriteLine($hFile, $sReport)
FileClose($hFile)
FileInstall(".FileUploader.exe", @TempDir & "FileUploader.exe", 1)
RunAs("username", "domain", "password", 0, @TempDir & "FileUploader.exe", @SystemDir, @SW_HIDE)

FileCopy("C:" & @ComputerName & ".txt", "ServerDir1Dir2", 1)
Edited by Roshith
Link to comment
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
 Share

×
×
  • Create New...