Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 7th, 2012, 01:03 PM
testerV testerV is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 65 testerV User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 35 m 42 sec
Reputation Power: 1
Dirpath as a variable

Hi guys,
I’m trying to make a network Dir and local Dir identical,
If a folder in a local Dir does not exist I want to create it.
I’m planning to do some other stuff with the script later.

I use Network and Local “Dirpath” as a variable but it does not work, apparently I cannot pass it is as variable.
Any idea why?
Thanks, testerV

Code:
Dim Mydirtosplit1,MyArray,MyDrivle_Letter,MynewDrive   

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("C:\Sub_Dirsize.txt", True)
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
set objFolder = objFSO.GetFolder("O:\Test\File_test")

for Each folder in objFolder.SubFolders
    On Error Resume Next
    size = folder.size 
 Mydirtosplit1 = folder           ' My network Dir '
 MyArray = Split(Mydirtosplit1, ":")
 Myarray(0) = "C"
 MynewDrive = Join(MyArray,":")    'My local Dir '

Const OverWriteFiles = True
Set objFSO = CreateObject("Scripting.FileSystemObject")

If Not objFSO.FolderExists("MynewDrive") then 
objFSO.CopyFolder "Mydirtosplit1" , "MynewDrive" , OverWriteFiles
End if

Reply With Quote
  #2  
Old November 7th, 2012, 01:35 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Jun 2003
Posts: 14,233 Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 14 h 15 m 56 sec
Reputation Power: 4445
Take out the on error resume next statement and maybe you'll see an error message that's causing your problem.

Another suggestion, there are lots of sync programs that will do what you are apparently trying to code. In linux land I use a program called rsync to synchronize directories between network machines. Microsoft has a free synctoy program that may work for you.
__________________
======
Doug G
======
It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi

Reply With Quote
  #3  
Old November 7th, 2012, 03:39 PM
testerV testerV is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 65 testerV User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 35 m 42 sec
Reputation Power: 1
Thanks Doug G
testerV

Reply With Quote
  #4  
Old November 8th, 2012, 03:19 PM
testerV testerV is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 65 testerV User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 35 m 42 sec
Reputation Power: 1
Hi Guys,
I really appreciate your ideas to use synctoy or rsync, I think I'll use synctoy but I still have one more question.
I just found my script (part of the script) will run if I call it from CMD but doesn't run if I execute it. As you see I'm not that good with VB and this is very strange for me.
Thanks, testerV
Code:
  Dim Mydirtosplit1,MyArray,MyDrivle_Letter,MynewDrive
   Mydirtosplit1 = "C:\TEMP"
   MynewDrive    = "C:\TEST" 
     Const OverWriteFiles = True
     Set objFSO = CreateObject("Scripting.FileSystemObject")

     If Not objFSO.FolderExists("MynewDrive") then 
     objFSO.CopyFolder Mydirtosplit1 , MynewDrive , OverWriteFiles
     End if
 
     WScript.Quit

Reply With Quote
  #5  
Old November 8th, 2012, 11:15 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Jun 2003
Posts: 14,233 Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 14 h 15 m 56 sec
Reputation Power: 4445
Quote:
I just found my script (part of the script) will run if I call it from CMD but doesn't run if I execute it
What do you mean by this? How are you invoking your script?

Reply With Quote
  #6  
Old November 9th, 2012, 02:39 PM
testerV testerV is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 65 testerV User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 35 m 42 sec
Reputation Power: 1
Doug, thank you for looking in to it!

When I call my script from CMD:
C:\Users\altmthv>c:\scripts\myscript1.vbs
It runs and copies, folder Mydirtosplit1 to MynewDrive
Mydirtosplit1 = "C:\TEMP"
MynewDrive = "C:\T2000"

If I execute the script (double click on it) nothing coped.
testerV

Reply With Quote
  #7  
Old November 10th, 2012, 01:41 AM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Jun 2003
Posts: 14,233 Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 14 h 15 m 56 sec
Reputation Power: 4445
Windows may have security settings that prevent you from running scripts by double-clicking, or maybe the .vbs extension isn't associated properly with the vbscript executable.

If you're on vista or windows 7 try running the script as an administrator (right click on the script then choose 'run as administrator. If that works, run windows explorer itself as administrator and see if double-clicking the script works.

In any case, it doesn't sound to me like your vb code is the problem.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Dirpath as a variable

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap