Jump to content

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


caocao81
 Share

Recommended Posts

.... 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?
Link to comment
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
Link to comment
Share on other sites

  • 2 weeks later...

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)

Link to comment
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
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

  • Recently Browsing   0 members

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