Sign in to follow this  
Followers 0
caocao81

How to eidt the file in another PC if i got the PC accout and password?

9 posts in this topic

I use the function FileOpen() to open the file in another PC. For example:

$CenterHostsFile = "\\192.168.76.15\D\hosts"

$file = FileOpen( $CenterHostsFile, 1)

but it did not work,Someone can help me? thanks!!

Share this post


Link to post
Share on other sites



.... it did not work,Someone can help me?

What do you mean it didn't work? If those 2 lines are your script, what evidence do you have that it didn't work? Looking at the example code in the Help file, you can see there are more than two lines. What are you expecting or wanting it to do?

Share this post


Link to post
Share on other sites

This attempt to edit "hosts" file on a remote PC - I don't know why - but it doesn't look "good" for me. I won't ask you though why would you want to do it ...


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

I use the function FileOpen() to open the file in another PC. For example:

$CenterHostsFile = "\\192.168.76.15\D\hosts"

$file = FileOpen( $CenterHostsFile, 1)

but it did not work,Someone can help me? thanks!!

Try it with a mapped drive:

$sShare = "\\192.168.76.15\D" 
$sMapDrv = DriveMapAdd("*", $sShare, 8)
If $sMapDrv <> "" Then
    $sCenterHostsFile = $sMapDrv & "\hosts" 
    $hFile = FileOpen($sCenterHostsFile, 1)
    If $hFile <> -1 Then
        MsgBox(64, "Success", "Successfully opened file: " & $sCenterHostsFile)
    Else
        MsgBox(16, "Error", "Error opening file: " & $sCenterHostsFile)
    EndIf
Else
    MsgBox(16, "Error", "Error mapping to share: " & $sShare)
EndIf

; Do stuff

FileClose($hFile)
DriveMapDel($sMapDrv)

If that 'D' is supposed to be the admin share of 'D:' then it should be 'D$'.

The option 8 for DriveMapAdd() will prompt for credentials if you are not already authenticated to the server.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I attempt to edit "hosts" file on a remote PC, but use my script, can't edit the file.someone can tell me how to edit the file on a remote PC? I have the password of the remote PC. Thanks!!

Share this post


Link to post
Share on other sites

I attempt to edit "hosts" file on a remote PC, but use my script, can't edit the file.someone can tell me how to edit the file on a remote PC? I have the password of the remote PC. Thanks!!

Have you tried using PsaltyDS solution? Yes? Didn't work? What was the error?


My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites

Have you tried using PsaltyDS solution? Yes? Didn't work? What was the error?

Sorry, what is PsaltyDS? when I use my script, programme have no response.

Share this post


Link to post
Share on other sites

Sorry, what is PsaltyDS? when I use my script, programme have no response.

You can use this, but you'll have to code your own _Generate* functions:

Func _PsaltyDS($food, $sleep, $caffine)
    If $food <> 0 Then
        If $sleep Or $caffine Then
            Return _GenerateBadJokes ()
        Else
            Return _GenerateREALLYBadJokes ()
        EndIf
    Else
        Return _GenerateGrouchyAnnoyance ()
    EndIf
EndFunc   ;==>_PsaltyDS

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  
Followers 0