Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

permcopy command in vbscript 1

Status
Not open for further replies.

elmurado

IS-IT--Management
Joined
Jul 15, 2003
Messages
673
Location
AU
Hi,
I'm trying to use permcopy to copy share ACL's on a set of user folders to a 'mirror image' of folders on another server.
i want to be able to read from a file and pass the strFolder ie folder name to the second half of my script.

I have this:
-----------------
On Error Resume Next

'open the script shell
set WSHShell = CreateObject("WScript.Shell")
set WSHShell = WScript.CreateObject("WScript.Shell")
'open the file
Set oTextStream = oFSO.OpenTextFile("flist.txt")
'make an array from the file
RemoteFOLDER = Split(oTextStream.ReadAll, vbNewLine)
'close the file
oTextStream.Close
For Each strFolder In RemoteFOLDER

Set objShell = CreateObject("WScript.Shell")
objShell.Run("""permcopy \\SERVERNAME"" & strFolder "\\SERVER2NAME""" & strFolder""")
Next
------------------------

It runs but there's no errors but nothing happens.

I can get the permcopy to run fine in a simple script eg:

-------------------

Set objShell = CreateObject("WScript.Shell")
objShell.Run("permcopy \\ssaserver username \\storage01 username")

So I guess somewhere in my bigger script my syntax is way off. I found something mentioning spaces etc and tried to fix it-syntax seems fine but still no good. Or have I got something wrong before that?
 
>objShell.Run("""permcopy \\SERVERNAME"" & strFolder "\\SERVER2NAME""" & strFolder""")
[tt]objShell.Run "permcopy \\SERVERNAME[highlight] [/highlight]" & strFolder & "[highlight] [/highlight]\\SERVER2NAME[highlight] [/highlight]" & strFolder[/tt]
 
Thanks dude-it all seemed to run through fine but i need to find out if the perms actually copied now when I can get back on to the remote machine. Your eagle eyes helped there.
 
Why is it sometimes the command can go in to brackets and sometimes it doesn't need to?
 
In vbs, you can safely do without a bracket for none, one or many arguments. Like
[tt] objShell.Run aaa,bbb,ccc[/tt]
In fact with this style, using bracket is an error.

If your method happens to give a return value and you want to capture the return, then you need the bracket.
[tt]x=objShell.Run(aaa,bbb,ccc)[/tt]
If the return is an object, you have to even attach a keywork set in front of x.

If you see some legacy usage of call (which might or might not revive in the future as a "cool" style that I do not think necessary), you have to use bracket.
[tt] call objShell.Run(aaa,bbb,ccc)[/tt]

In the special case of one argument, using bracket has special meaning of "evaluating" it. But that is another story.
 
Thanks mate. That's helped me out a lot to undertsand what's needed and when.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top