Jump to content
Sign in to follow this  
NickBtheITguy

_FileWriteLog to a network share that requires login

Recommended Posts

NickBtheITguy

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.

Share this post


Link to post
Share on other sites
dillonlim

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.

Share this post


Link to post
Share on other sites
ProgAndy

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

Share this post


Link to post
Share on other sites
udgeen

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:

Share this post


Link to post
Share on other sites
NickBtheITguy

Thanks guys! You gave me some things to think about. I'm going to test a few of the methods and see which one I end up using.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.