Jump to content

Recommended Posts

Posted

I am trying to elevate my FileOpen() to read a file that is remote (no problem there), and unfornately needs to have elevated permissions to be read. Any help? Can not use any other 3rd party software to help with this other than this script.

Posted

No this is being done on a remote computer that the users have no access to admin info. I know how to runas, but I can not properly either get the whole script elevated to admin level or an individual function or just the FileOpen() function.

Posted

Hmmm, I see.

Next questions would be:

- Are these computers (yours, remote?) in a domain?

- Are you admin in that domain?

- Are you running your script locally or at the remote computer?

Maybe you'd solve this with e.g. PSTools by SysInternals?

Posted (edited)

They are my remote computers (work), I am an admin, and I'm running the script remotely.

Func ReadFile($ecmlocation)

$file = FileOpen($ecmlocation)
;Check if file opened for reading OK
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf

;Read in lines of text until the EOF is reached
$eachline=1 ;line to be read
While $eachline <4 ;line by line until line 4
$line = FileReadLine($file)
$PosOfStore = StringInStr ($line,"glob_store_code=") ;it looks for the string "glob_store_code=", >0 means found something matching that!
if $PosOfStore >0 Then ;if does not find it will quit the loop
$store_id = stringmid($line, $PosOfStore + 20,4) ; if it finds something it will grab the store ID Ex: 003A
ExitLoop
Else
$store_id ="nothing" ; if does not find anything it will quit and return "nothing"
EndIf
Wend
FileClose($file)
Return $store_id
EndFunc

I am trying to get this to pull up from the 2nd terminal, information on the first terminal, but it requires elevation to open the file on that network as both computers there are users.

Edited by Meldrath

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...