Jump to content

File question


 Share

Recommended Posts

  • Developers

You aren't making a great start here in our forums.

I have removed this question from a totally unrelated thread and merged the other 3 created topics.

Please stick to a single thread/post when you have a question.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

You also need to study the FileOpen/Filewrite/FileClose in the helpfile as you are mixing things up... should be something like:

Local $Publicip = _GetIP()
Local $File = FileOpen("ip.txt", 1)
FileWrite($File, $Publicip)
FileClose($File)

 

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

So, now How do i save ip.txt to a different location rather then the desktop because when i run the script that is where it gets saved to

Specify the correct target directory in the script .. maybe?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Seriously?

Change your filename to a full path and filename.

If you do not understand what a path is I'd have to wonder what business you have at the flesh end of a keyboard, let alone scripting.

Use web search to learn basic computing first would be your best bet.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

How about @WindowsDir & "ip.txt" ?  The way you wrote it won't work, as FileWrite only takes 2 parameters, you gave it 3. Even if it had worked, all it would do is write the text of the macro @WindowsDir (Usually C:Windows) to the text file.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I have tried both of those filewrite("C:" "ip.txt")

well could someone test it and see if they can get ip.txt to the C: directory rather then the desktop ?

Here is the code

#include <Inet.au3>
$PublicIP = _GetIP()
FileOpen("ip.txt", 1)
FileRead($PublicIP, 1)
FileWrite("ip.txt", $PublicIP)

and run it and you'll see what i mean it will end up on the desktop

and i dont want it there sorry if this is an inconvenience but im very annoyed at this point and would

just like to get it saved to c:

oh and this is going to be a remote administration tool by the way in case any of you were wondering.

Edited by andrew545
Link to comment
Share on other sites

  • Developers

Why are you creating 2 literal strings in stead of 1?

Just add c: in front of the filename inside of the "".

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

and i dont want it there sorry if this is an inconvenience but im very annoyed at this point and would

just like to get it saved to c:

oh and this is going to be a remote administration tool by the way in case any of you were wondering.

 

You keep complaining about how annoyed you are, or how "aggervating" (your horrible spelling, not mine) this is for you. Yet you aren't listening to the help people are trying to provide to you. First off, since you are on Windows 8 and you're trying to save to the root of C:, you need to ensure #RequireAdmin is at the top of your script.

Secondly, this:

FileRead($PublicIP, 1)

..makes no sense at all. Go back and look at the first parameter for FileRead, to see the mistake. 

Lastly, as has been suggested several times, try a literal path for the file.

#RequireAdmin
#include <Inet.au3>

$PublicIP = _GetIP()
FileOpen("C:\ip.txt", 1)
;>>>>FileRead($PublicIP, 1) ***Get rid of this, it makes no sense***
FileWrite("C:\ip.txt", $PublicIP)

...this works just fine on WIN8

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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...