Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

.vbs script creat read/write folder problem

Posted on 2004-09-01
6
Medium Priority
?
2,308 Views
Last Modified: 2013-12-03
i am writing a script to crete a folder and populate it with some logs. Simple enough right? whenever I create this folder via .vbs, it is set to read-only attribute, and I can't write anything to it. I need this changed with script though, because it is part of another script running on 300 or so computers.  Here is the following two methods i've already used that keep defaulting to read only access

1#
Set FSO = CreateObject("Scripting.FileSystemObject")
   FSO.CreateFolder(c:\dufftest65)

2#
folder= "emma04fix"
path= "c:\"&folder
duffcmd= "cmd /c md "& path
Call Wshshell.run(duffcmd,0,0)

Any help as to something I need to add or change would be greatly appreciated! I think 125 pts should be more then enough but hopefully that will get me some quick answers!
0
Comment
Question by:duffbk4
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 1

Author Comment

by:duffbk4
ID: 11952194
Ok, I have pushed the points up cause I need this as soon as possible.  Thanks for any help!
0
 
LVL 16

Accepted Solution

by:
nonubik earned 2000 total points
ID: 11952759
It is strange that is created read-only. You can set folder's attribute

Set FSO = CreateObject("Scripting.FileSystemObject")
   FSO.CreateFolder(c:\dufftest65)
   If FSO.attributes and 1 Then
      FSO.attributes = FSO.attributes - 1


1 is the value for readonly
0
 
LVL 86

Expert Comment

by:jkr
ID: 11952843
That should just work fine using

Function CreateFolderDemo
   Dim fso, f
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.CreateFolder("c:\New Folder")
   CreateFolderDemo = f.Path
End Function

But, if the parent folder is set to 'read only' for your account and these settings are to be inherited by the contained objects, you'll end up with a newly created read-only folder. To change that, you could use

Function ToggleReadOnlyBit(filespec)
   Dim fso, f
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFolder(filespec)
   If f.attributes and 1 Then
      f.attributes = f.attributes - 1
      ToggleReadOnlyBit = "ReadOnly bit is cleared."
   Else
      f.attributes = f.attributes + 1
      ToggleReadOnlyBit = "ReadOnly bit is set."
   End If
End Function

0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
LVL 16

Expert Comment

by:nonubik
ID: 11952888
heh, I was a little bit faster :o)
0
 
LVL 1

Author Comment

by:duffbk4
ID: 11953519
Thanks for the help! Both of you.
0
 

Expert Comment

by:uber-goober
ID: 12126948
I am having exactly the same problem.  My directory has the read-only flag blocked out, (not checked) and I get the permissions error when I try to copy a file to it.  I have used the following code to explicitly set the bits to 16 for my directory (directory - not read-only).  Can someone help?

Set BinFolder = FolderObject.CreateFolder(InstallDir & "\Support\" & EnvLabel & "\BIN")
                        
BinFolder.Attributes = NOT 239 'set attributes to 16
msgbox "BinFolder.Attributes = " & BinFolder.Attributes,,"DEBUG" 'verify attribute setting
      
FolderObject.CopyFile CurrentInstallDir & "\BIN\winstore.sec", BinFolder, TRUE 'HOSED!@

0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question