Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


File permissions for OpenTextFile (append)

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,60228
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> File permissions for OpenTextFile (append)
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 File permissions for OpenTextFile (append) - 5/14/2008 10:54:23 PM   
  asgaroth

 

Posts: 12
Score: 0
Joined: 5/14/2008
Status: offline
Hello,

I have a question regarding file permissions needed to append text to a File.

I am currently writing a logon script which maps networks drives. Mapping should be logged in a logfile.

This logfile is and has to be write only for the users.

When i use:
FileSystemObject.OpenTextFile("\\Path\"& UserName &".txt", 8 )

there is a File Permission Error...

Everything works fine if i give myself write privileges.

Is it possible to append to the logfile without changing the permissions to read and write?

Best Regards, Jo
 
 
Post #: 1
 
 RE: File permissions for OpenTextFile (append) - 5/15/2008 12:08:21 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
If you want to append then the rights must be read/write since an append must first read the file the write additions to it.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to asgaroth)
 
 
Post #: 2
 
 RE: File permissions for OpenTextFile (append) - 5/15/2008 12:24:30 AM   
  asgaroth

 

Posts: 12
Score: 0
Joined: 5/14/2008
Status: offline
Thats bad...
We wanted to konvert all our logon scripts from kickstart to VBS and kickstart somehow managed to append without having read rights...
Maybe its possible to change rights temporary for logon or something...

Best Regards, Jo

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: File permissions for OpenTextFile (append) - 5/15/2008 12:33:23 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
I really don't see how Kicks could append without read/write as well. Appending always requires those two actions, read then write. Could you post the pertinent portion of the kicks script?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to asgaroth)
 
 
Post #: 4
 
 RE: File permissions for OpenTextFile (append) - 5/18/2008 4:12:44 AM   
  asgaroth

 

Posts: 12
Score: 0
Joined: 5/14/2008
Status: offline
Sure, here it is:

$logfilename = "\\server\logs\%username%.txt"

use n: /delete
use n: "\\server\email"
$x=dir("n:")
open(4, $logfilename, 4+1)
writeline(4, "Mounting Drives at: " + @DATE + " " + @TIME + " " + @HostName + @CRLF)

Hope that helps...

Best regards, asgaroth

(in reply to ebgreen)
 
 
Post #: 5
 
 RE: File permissions for OpenTextFile (append) - 5/27/2008 8:34:03 PM   
  asgaroth

 

Posts: 12
Score: 0
Joined: 5/14/2008
Status: offline
So now i found out that it works when i use

wshShell.run "CMD /C echo s: mounted >> " & logfile

Somehow the DOS >> command doesn't need read rights to append.
(Or it has read rights because its a system component).

That workaround works for my purposes.

I only need to find out how to prevent the Command prompt from poping up every time something is written in the logfile.

(in reply to asgaroth)
 
 
Post #: 6
 
 RE: File permissions for OpenTextFile (append) - 5/28/2008 1:42:14 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
wshShell.run "CMD /C echo s: mounted >> " & logfile, 0

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to asgaroth)
 
 
Post #: 7
 
 RE: File permissions for OpenTextFile (append) - 5/28/2008 3:38:50 PM   
  TKS


Posts: 153
Score: 0
Joined: 5/16/2008
Status: offline
quote:

ORIGINAL: ebgreen

wshShell.run "CMD /C echo s: mounted >> " & logfile, 0


Hi ebgreen,

What does the entire code for this .bat look like?

-TKS

(in reply to ebgreen)
 
 
Post #: 8
 
 RE: File permissions for OpenTextFile (append) - 5/29/2008 1:35:44 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
What .bat?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to TKS)
 
 
Post #: 9
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> File permissions for OpenTextFile (append) Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts