Jump to content

lunch the win32 copy or move command via batch file?


graysky

Recommended Posts

Is there a way I can start the windows xp copy or move command rather than using the DOS command? (I.e. launch whatever exe windows uses when a user does a drag-and-drop that will invoke the standard "Copying ..." dialogbox?

Link to comment
Share on other sites


Copy/move operations that show the progress dialog can be scripted using a Shell.Application object. VBScript example:

CreateObject("Shell.Application").NameSpace("C:\Target").CopyHere "C:\Source"

This will copy the C:\Source folder to the C:\Target folder (resulting in a C:\Target\Source folder).

Link to comment
Share on other sites

Here is a VBS Script that

1:\ Inputbox to set the Copy To Spot, if the Cancel Button is pressed or no text was detected

it will produce a Message Box then quit.

2:\ Inputbox to set the Copy From Spot, if the Cancel Button is pressed or no text was detected

it will produce a Message Box then quit.

3:\ It then checks to see if the folder for the Copy To Spot exists if the Folder does not exists then

it makes the Folder for the Copy To Spot

Save As ShellCopy.vbs

Const moveOrRenameTrue = 8, yesToAll = 16, displayProgress = 256, noConfirmDirCreate = 512
Dim CopyToSpot, CopyFrom, Fso, Shell, Text
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Shell = CreateObject("Shell.Application")
Text = "The User Has Selected To Quit And Not Copy Nothing" & vbCrLf &_
"Or There Was No Path Given For The File Or Folder"
'/-> The Folder Where You Want To Copy To
CopyToSpot = InputBox("Type In The Path To Copy To " & vbCrLf &_
"Example : C:\SomeFolder" ,"Copy To Spot",,5500,4800)
If CopyToSpot <> "" Then
'/-> The File Or Folder That Goes To The CopyToSpot
CopyFrom = InputBox("Type In The Path Of The File Or Folder That You Want " &_
"To Copy To This Location " & CopyToSpot, "Copy From",,5500,4800)
If CopyFrom <> "" Then
'/-> If The CopyToSpot Does Not Exists It Makes The Folder For The CopyToSpot
If Not Fso.FolderExists(CopyFrom) Then Fso.CreateFolder(CopyFrom) End If
Shell.NameSpace(CopyToSpot).CopyHere(CopyFrom),yesToAll + displayProgress
Else
'/-> This Is Cancel Or No Text Was Detected From The CopyFrom InputBox
MsgBox Text, 0 + 32 + 4096,"User Cancel"
End If
Else
'/-> This Is Cancel Or No Text Was Detected From The CopyToSpot InputBox
MsgBox Text, 0 + 32 + 4096,"User Cancel"
End If

Edited by gunsmokingman
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...