Jump to content

_FileWriteLog to a network share that requires login


Recommended Posts

In my script I am using _FileWriteLog to write log files. I want to be able to write them to a network share using a unc path. The only problem I am running into is that the share requires a login. I am not sure how to pass the credentials so that my script will write to the share. I saw the RunAs but I don't really understand how I could use that with _FileWriteLog.

Link to comment
Share on other sites

In my script I am using _FileWriteLog to write log files. I want to be able to write them to a network share using a unc path. The only problem I am running into is that the share requires a login. I am not sure how to pass the credentials so that my script will write to the share. I saw the RunAs but I don't really understand how I could use that with _FileWriteLog.

Try passing this command in your script:

net use \\<path of network share> /user:<login> <password>

Downside to that is your password is unencrypted and can be seen in your script.

Link to comment
Share on other sites

You could ask for the password each time the Script starts :(

also, you can make the login persistent :mellow:

(type net use /? in you cmd for more information)

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Or use the same command on AutoIt. Its just the same as "net use", couse net.exe can be disabled by system administrator : )

DriveMapAdd ( "", "\\server\share", 0, "domain\username", "password" )
or
DriveMapAdd ( "", "\\server\IPC$", 0, "domain\username", "password" ) - for windows file servers only

the second variant is almost interesting, couse the share can be disabled while server is alive

that'll let you to test the log file existance by

FileExists("LogFileFullPath")
before writing to it

...and if the logserver is far away (for example on the other side of vpn tunnel), its a good idea to test it by Ping() command first.

The only problem is the same: password in your code... any ideas to write own syslog server for windows? :mellow:

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