Learn how to Make Money Online doing freelancing, Affiliate Marketing, Blogging and many more ...
Go4Expert
Go4Expert RSS Feed

Go Back   Programming and SEO Forum >  Go4Expert > Queries and Discussion > Programming > Visual Basic ( VB )

Reply  Copy HTML to Clipboard  Copy BBCode to Clipboard  | More
 
Bookmarks Thread Tools Search this Thread Display Modes
Old 12-26-2009, 03:29 PM   #1
Newbie Member
 
Join Date: Dec 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
dariods is on a distinguished road

Using Xcopy in VBScript


Unfortunately, xcopy doesn't take place. Could someone explain me what's wrong with the script and point me in the right direction to achieve points (1) - (5)? Thanks.This is my script
Code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set wshShell = WScript.CreateObject("WScript.Shell")
strUserName = wshShell.ExpandEnvironmentStrings("%USERNAME%")

' Discover Current Drive Path
curDrv = objFSO.GetParentFolderName(WScript.ScriptFullName) 'Drive Path
' USB Drive  and folder Path
upath = curdrv & "\ACG" 

' Source
avg8 = "c:\Docume~1\alluse~1\applic~1\avg8\update\downloa  d\*.*"
avg9 = "c:\Docume~1\alluse~1\applic~1\avg9\update\downloa  d\*.*"

If struserName = DARIO Then 
  '(1) GOTO Update
End If

If Not objFSO.FolderExists (upath) Then
  objFSO.CreateFolder (upath)
End If

If objFSO.FolderExists (avg9) Then
  'WshShell.Run "xcopy c:\Docume~1\alluse~1\applic~1\avg9\update\download  \*.* usbdrive:\acg /D", , True
  '(2) WshShell.Run "xcopy avg9 upath /D", , True
  WshShell.Run "xcopy " & avg9 & " " & upath & " /D", , True
End If

If objFSO.FolderExists (avg8) Then
  'WshShell.Run "xcopy c:\Docume~1\alluse~1\applic~1\avg8\update\download  \*.* &    usbdrive:\acg & /D", , True
  '(3) WshShell.Run "xcopy avg8 upath /D", , True
  WshShell.Run "xcopy " & avg8 & " " & upath & " /D", , True
End if

MsgBox "Definition Files Copied to your USB Drive @ " & upath, vbInformation, "Copy   Success..."
WScript.Quit

' Update 
If Not objFSO.FolderExists("C:\Updates") Then
  objFSO.CreateFolder "C:\Updates"
End If

If objFSO.FolderExists (upath) then
  Wshshell.Run "xcopy " & upath  & " " & "C:\Updates /D", , True '(4)
  MsgBox "Update Files Copied to C:\Updates" , vbInformation, "Copy Destination"
End IF

' Process
Message = "Click OK to Start Updating product." & vbCr & vbCr
Message = Message & "Click Cancel or (Esc) to Exit." &vbCr & vbCr
Message = Message & "Keep Selecting OK until you get" & vbCr
Message = Message & "the Message :-" & vbCr & vbCr
Message = Message & "''No New Update Files Available''" & vbCR & vbCR
X = MsgBox(Message, vbOKCancel, "AVG Update Module")

Select Case X
  Case vbCancel 
    MsgBox (strUserName & " cancelled the process.") , vbCritical, "Operation Terminated."
    Wscript.Quit

  Case vbOK
    If objFSO.FileExists("C:\Program Files\AVG\AVG89\avgupd.exe") Then
      WshShell.Run "C:\Program Files\AVG\AVG9\avgupd.exe" /source=folder /path="C:\Updates"
    End If

    If objFSO.FileExists("C:\Program Files\AVG\AVG8\avgupd.exe") Then
      WshShell.Run "C:\Program Files\AVG\AVG8\avgupd.exe" /source=folder /path="C:\Updates"
      '(5) Loop to Process
    End If
End Select

Last edited by shabbir; 12-26-2009 at 05:07 PM. Reason: Code blocks
dariods is offline   Reply With Quote
Old 12-27-2009, 06:50 PM   #2
Invasive contributor
 
nimesh's Avatar
 
Join Date: Apr 2009
Location: Mumbai
Posts: 767
Thanks: 111
Thanked 81 Times in 60 Posts
Rep Power: 3
nimesh will become famous soon enoughnimesh will become famous soon enough
Send a message via Yahoo to nimesh

Re: Using Xcopy in VBScript


Can you give the error that you get for the script?

First try with just a simple statement of 2-3 lines, instead of going for the whole code.
See if it works.
__________________
Nimesh aka KFP
My Blog | My Moments | My Profile
Save Time Effortlessly OR Spend Time Efficiently. The Choice Is Yours
nimesh is offline   Reply With Quote
Old 12-28-2009, 12:00 AM   #3
Newbie Member
 
Join Date: Dec 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
dariods is on a distinguished road

Re: Using Xcopy in VBScript


Quote:
Originally Posted by nimesh View Post
Can you give the error that you get for the script?

First try with just a simple statement of 2-3 lines, instead of going for the whole code.
See if it works.
I get the msgbox of Copy Success but nothing gets copied
dariods is offline   Reply With Quote
Reply  Copy HTML to Clipboard  Copy BBCode to Clipboard  | More


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads / Articles
Thread Thread Starter Forum Replies Last Post
Subroutines in VBscript Sanskruti Visual Basic [VB] 2 09-25-2008 06:22 PM
VBScript Tutorial nehas HTML/DHTML/CSS -JavaScript/VBScript 3 07-07-2007 07:19 PM
Functions in VBScript Sanskruti HTML/DHTML - JavaScript/VBScript 0 05-07-2007 05:30 PM
Working with operators in VBScript Sanskruti HTML/DHTML - JavaScript/VBScript 0 04-18-2007 07:51 PM

 

All times are GMT +5.5. The time now is 05:21 AM.