f



Batch file operation copies files to desktop

Hi,

I would like to write a batch file that can do the following:

-Copy two files (an .mdb and a .bat) from a location on the network
given as an UNC path (e.g. \\servername\sharename\...\myFile.mdb) and
save it to the currently logged on user's desktop, using the generic
Windows location for <dekstop> whether it is 98, NT or XP.

Anybody know how to do this? Thanks in advance.

Regards,
Jean

0
jeanjanssens
4/14/2005 1:05:49 PM
comp.os.ms-windows.misc 2965 articles. 1 followers. vnagrik (21) is leader. Post Follow

7 Replies
481 Views

Similar Articles

[PageSpeed] 52

jeanjanssens@hotmail.com wrote:

> Hi,
> 
> I would like to write a batch file that can do the following:
> 
> -Copy two files (an .mdb and a .bat) from a location on the network
> given as an UNC path (e.g. \\servername\sharename\...\myFile.mdb) and
> save it to the currently logged on user's desktop, using the generic
> Windows location for <dekstop> whether it is 98, NT or XP.
> 
> Anybody know how to do this? Thanks in advance.
> 
> Regards,
> Jean
> 

If you run the batchfile from the machine the user is logged in this 
should not be too hard.

You can manually create a file somewhere to do the identification of the 
OS type and thus the location of the desktop folder, and use like an if 
and goto system, or try and use some built-in variables to determine the 
OS type.

Wim
0
Wim
4/14/2005 1:41:31 PM
On 14 Apr 2005 06:05:49 -0700, jeanjanssens@hotmail.com wrote:

>Hi,
>
>I would like to write a batch file that can do the following:
>
>-Copy two files (an .mdb and a .bat) from a location on the network
>given as an UNC path (e.g. \\servername\sharename\...\myFile.mdb) and
>save it to the currently logged on user's desktop, using the generic
>Windows location for <dekstop> whether it is 98, NT or XP.
>
>Anybody know how to do this? Thanks in advance.
>
>Regards,
>Jean

With Win2K / WinXP you can use the %HOMEPATH% variable in a batch file
to point to the current user's desktop. Thus If user JoeBob is logged
in, the command

Copy \\SERVER\myfile.mdb "%HOMEPATH%\Desktop" 

will copy the file MYFILE.MDB from the server onto his desktop.

Note the quites around the destination; since the default home
directory for Win2K/XP is the "Documents and Settings" folder, you
need quotes to handle the long-filename-with-spaces

I'm not sure about Windows9x...


0
Spalls
4/14/2005 3:18:16 PM
> With Win2K / WinXP you can use the %HOMEPATH% variable in a batch file
> to point to the current user's desktop. Thus If user JoeBob is logged
> in, the command
> 
> Copy \\SERVER\myfile.mdb "%HOMEPATH%\Desktop" 
> 
> will copy the file MYFILE.MDB from the server onto his desktop.
> 
> Note the quites around the destination; since the default home
> directory for Win2K/XP is the "Documents and Settings" folder, you
> need quotes to handle the long-filename-with-spaces
> 
> I'm not sure about Windows9x...
> 

Windows 9x should use C:\Windows\Desktop normally, but if you have 
enabled profiles it could be C:\Windows\profiles\username\Desktop
0
Wim
4/14/2005 5:22:34 PM
Thanks for the answers everyone.

I tried using the syntax, but it seems to have a problem with the
"%HOMEPATH%\Desktop"  part. Says that there is a syntaxt error.

When I try only "%HOMEPATH%" i get "Access denied", although I can open
this folder through Explorer

Strange....

0
jeanjanssens
4/18/2005 8:03:57 AM
On 18 Apr 2005 01:03:57 -0700, jeanjanssens@hotmail.com wrote:

>Thanks for the answers everyone.

>I tried using the syntax, but it seems to have a problem with the
>"%HOMEPATH%\Desktop"  part. Says that there is a syntaxt error.

>When I try only "%HOMEPATH%" i get "Access denied", although I can open
>this folder through Explorer

>Strange....

I just realized that the %HOMEPATH% doesn't specify the drive, so if
you are running the batch file on a different drive, it won't work
unless you use the %HOMEDRIVE% variable too. E.g.,

copy \\fileserv\netdir\file.txt
"%HOMEDRIVE%%HOMEPATH%\desktop\file.txt

(all one line, of course; darn word-wrap! There's a space between
file.txt and "%homedrive too)

By the way, you can find out what other nifty environmental variables
have been created by going to the command prompt and typing SET. 

I don't know about the access denied bit, but the syntax error may be
caused by a missing "quote" around the %HOMEPATH% bit; those spaces in
"Documents and Settings" are *really* annoying.

0
Spalls
4/18/2005 2:59:52 PM
Spalls Hurgenson wrote:
> On 18 Apr 2005 01:03:57 -0700, jeanjanssens@hotmail.com wrote:
>
> >Thanks for the answers everyone.
>
> >I tried using the syntax, but it seems to have a problem with the
> >"%HOMEPATH%\Desktop"  part. Says that there is a syntaxt error.
>
> >When I try only "%HOMEPATH%" i get "Access denied", although I can
open
> >this folder through Explorer
>
> >Strange....
>
> I just realized that the %HOMEPATH% doesn't specify the drive, so if
> you are running the batch file on a different drive, it won't work
> unless you use the %HOMEDRIVE% variable too. E.g.,
>
> copy \\fileserv\netdir\file.txt
> "%HOMEDRIVE%%HOMEPATH%\desktop\file.txt
>
> (all one line, of course; darn word-wrap! There's a space between
> file.txt and "%homedrive too)
>
> By the way, you can find out what other nifty environmental variables
> have been created by going to the command prompt and typing SET.
>
> I don't know about the access denied bit, but the syntax error may be
> caused by a missing "quote" around the %HOMEPATH% bit; those spaces
in
> "Documents and Settings" are *really* annoying.


SET (from the command line) shows all the variables availaable.  I used
the following to copy to a users Desktop:

%USERPROFILE%\Desktop

0
Smitch
5/13/2005 2:49:19 PM
More followup:  below is the sub created using information from another
posting:

Private Sub Command201_Click()
Dim CommandLine As String
    Dim FileSpec As String
    Dim VDesktop As String


    FileSpec = "\\abyss\shared-data\Internal Controls\Control
Matrix\Stellent Reporting Module.mdb"

    VDesktop = "%USERPROFILE%\Desktop"

    CommandLine = "copy """ & FileSpec & _
                             """ """ & VDesktop & """"

  Shell Environ("comspec") & " /c " & CommandLine, vbHide
  Quit
End Sub

This copies a file from a network sharefolder (per the FileSpec
variable), then copies it to the user's desktop.  Works great.

0
Smitch
5/13/2005 4:45:26 PM
Reply:

Similar Artilces:

Batch file
Oh ladies and gentlemen do I need help (in more ways then one but let's get on to it). I have written a batch file for a client to backup a computer's partitions onto an external hard drive. The computer is running XP Professional, ALL PARTITIONS and the external hard disk is NTFS. I have a script for every computer - THEY ALL WORK except one. I am having problems on one of the clients partitions (F:). It is a 8.6 GIG partition that is in size 40 GIG (NTFS) and it is shared. Ok here's what's happening. The code for this file is posted below. Now before I continue let me say - if I simply do a select all, drag and drop of the contents on F: onto the external drive I have not a single problem. no errors - no nothing. NO PROBLEMS. YAY WINDOWS. But this is about scripts ... this is about pain. Here's the script. @ECHO OFF REM Create Directories rem md H:\Ibiza\Backup\Julia rem md H:\Ibiza\Backup\Julia\"My Documents" md H:\"Ibiza\Backup"\Main REM COPY MY DOCUMENTS rem xcopy /E/C/Y C:\"Documents and Settings\Paul Charlton\My Documents" H:\Ibiza\Backup\Julia\"My Documents" REM COPY VILLAS FOLDER xcopy /E/C/Y F:\ H:\Ibiza\Backup\Main REM COPY OUTLOOK FILE rem xcopy/E/C C:\"Documents and Settings\Paul Charlton\Local Settings\Application Data"\Microsoft\Outlook\*.* H:\Ibiza\Backup\Julia ECHO * ECHO * ECHO COPY PROCESS COMPLETED SUCESSFULLY! pause cls EXIT Ok so eve...

Cannot Delete File? Long Path Tool Can - http://CannotDeleteFile.net LONG PATH Tool
Cannot Delete File? Long Path Tool Can - http://CannotDeleteFile.net LONG PATH Tool - Windows tool to copy or delete files and folders with path too long error Windows tool to copy or delete files and folders with path too long or filename too long error. Just browse to the file and press a button to copy or detele it, thats it! The application solves the problem with inability to copy and delete files and folders with long paths in Explorer. They could be created by virus/adware/Mac OS/other software. Normally one can't access such files under Windows and therefore can't ...

http://LongPathTool.com
http://LongPathTool.com - copy and delete path too long files Windows tool to copy or delete files and folders with path too long or filename too long error. Just browse to the file and press a button to copy or detele it, thats it! The application solves the problem with inability to copy and delete files and folders with long paths in Explorer. They could be created by virus/adware/Mac OS/other software. Normally one can't access such files under Windows and therefore can't copy or delete them either. Clean up files. Alows to copy and delete files that has path longer the...

http://LongPathTool.com - LONG PATH Tool
http://LongPathTool.com - LONG PATH Tool - Windows tool to copy or delete files and folders with path too long error Windows tool to copy or delete files and folders with path too long or filename too long error. Just browse to the file and press a button to copy or detele it, thats it! The application solves the problem with inability to copy and delete files and folders with long paths in Explorer. They could be created by virus/adware/Mac OS/other software. Normally one can't access such files under Windows and therefore can't copy or delete them either. Clean up files...

How to copy a file to a file with a prefixed file name
I'm trying to write a program that will archive selected files to an archive directory. The files in the archive directory will have a prefix in the format yyyymmdd-hhmmss-filename.ext. So, if the file is called "somefile.dat", then the filename in the archive directory should be "20090522-164325-somefile.dat". I'm using Clipper's COPY FILE command to do the copy. I can't figure out how to get the prefix in front of the file name. Creating the prefix string is no problem, but I can't figure out how to tack that onto the front of the filename. If I...

File::Copy::copy With File Handles
The documentation for File::Copy warns against using file handles as arguments: Note that passing in files as handles instead of names may lead to loss of information on some operating systems; it is recommended that you use file names whenever possible. Does this refer to handles created with the older FileHandle module (which is used in the module's synopsis), IO::Handle subclasses, or both? In either case what's the issue with handles that may lead to data loss? Quoth MaggotChild <hsomob1999@yahoo.com>: > The documentation for File::Copy warns agai...

A free utility for direct copy of Tandem files into Ms Sql, Ms Excel and flat text files
It's an 'Ftp-like' command line utility. You can copy Tandem Enscribe Files and Sql Tables into MS Sql server tables, MS Excel files or flat text files. Filter can be applied on rows and columns, both for Enscribe Files and Sql tables. It's free. Downloadable from http://free.x3.hu/peak-tibor/ Tibor PE�K ...

copying a file from windows file system to ext2 and ext3
hi all could anybody please tell me how can i copy a file from windows file systems like FAT12, FAT16,FAT32 and NTFS to EXT2, and EXT3. Is their any function in python that we can do the above Thanks in advance Yogi On Tue, 10 Jan 2006 15:59:01 -0800, muttu2244 wrote: > hi all > > could anybody please tell me how can i copy a file from windows file > systems like FAT12, FAT16,FAT32 and NTFS to EXT2, and EXT3. > Is their any function in python that we can do the above > > Thanks in advance > Yogi I'm sure more experienced hands will add comments here, but I believe that's strictly dependent upon having the correct filesystem drivers available on the system in question. Once you've mounted a Windows-type file system on Linux you can manipulate the files that live there just as if they were created on a real OS :) Dan muttu2244@yahoo.com wrote: > hi all > > could anybody please tell me how can i copy a file from windows file > systems like FAT12, FAT16,FAT32 and NTFS to EXT2, and EXT3. > Is their any function in python that we can do the above > > Thanks in advance > Yogi > I suspect that you are going to need to supply more information to get a good answer. 1) Which platform is the python program running on Windows/Linux? 2) If Linux, how is the FAT (or NTFS) partition mounted (smbclient)? 3) If Windows, you can ftp the file to the Linux partition (see Python ftplib) or use SAMBA to expose a share to...

file.exe file generation from file.m file
How to generate application (*.exe) file from *.m file, which has lots of graphics. Program was written for image watermarking by using image processing toolbox. I want to send this program some where else but with out sowing the program codes. By this *.exe no need to use matlab6.5 platform. Also tell me How to generate *.p file from *.m file Which is hide the code to user but for run this program need matlab6.5 Please give me some idea about it. it is very urgent for me. I will be very great full to you "Biswajit Kar" <hibiswajitkar@rediffmail.com> wrote in message ne...

OS 9 app to batch-rename files based on file date?
I have several folders with 50 to 500 files each in which the file names are a string of text followed by a three-digit number ("example-123"). I'd like to rename the files based on the file date, such that the earliest file would be "example-001," the next-earliest "example-002" and so forth. Is there an OS 9 app that would do this? TIA -- D.F. Manno dfm2a3l0t2@spymac.com "The work goes on, the cause endures, the hope still lives and the dream will never die." ...

OS X file associations lost on files restored to Windows server
We recently migrated from a Novell to a Windows 2003 server and all of the files copied to the directories that do not have extensions (as they were created by Mac users) lost their associations. The only way that they are reassociated is if we add file extensions or each file is opened and closed (which changes the date). As we have tens if not hundreds of thousands of files, the manual approach is impossible. Is there a program for OS X that recognizes the proper associations and adds a file extension or just reassociates the files, displaying the proper icon? I found one program, but yo...

Finding a CD drive from within a Batch file and copying files to HDD
I need to write a batch file that has the ability to find the CD-ROM drive, then find a directory on that drive and copy four files from the CD to the C: drive. Here is a copy of the copy command that I am using, assuming that the D: is the CD-ROM drive. copy d:\b_paf_for_beginners\copy_a_to_c_macro_folder\MaleMar1.fld c:\"Program Files"\"FamilySearch"\Paf5\MaleMar1.fld copy d:\b_paf_for_beginners\copy_a_to_c_macro_folder\MaleMar1.lay c:\"Program Files"\"FamilySearch"\Paf5\MaleMar1.lay copy d:\b_paf_for_beginners\copy_a_to_c_macro_folder\Qualifi1.f...

Finding a CD drive from within a Batch file and copying files to HDD
I need to write a batch file that has the ability to find the CD-ROM drive, then find a directory on that drive and copy four files from the CD to the C: drive. Here is a copy of the copy command that I am using, assuming that the D: is the CD-ROM drive. copy d:\b_paf_for_beginners\copy_a_to_c_macro_folder\MaleMar1.fld c:\"Program Files"\"FamilySearch"\Paf5\MaleMar1.fld copy d:\b_paf_for_beginners\copy_a_to_c_macro_folder\MaleMar1.lay c:\"Program Files"\"FamilySearch"\Paf5\MaleMar1.lay copy d:\b_paf_for_beginners\copy_a_to_c_macro_folder\Qualifi1.f...

Desktop/File management support on MS Windows
Are there any Python libraries that can trash files (move to Trash, not delete) or for example return a list of applications that can open given file? I can't find anything related to this for Windows. On Dec 31, 11:08=A0am, "riklau...@gmail.com" <riklau...@gmail.com> wrote: > Are there any Python libraries that can trash files (move to Trash, > not delete) or for example return a list of applications that can open > given file? I can't find anything related to this for Windows. try pywin32 http://python.net/crew/mhammond/win32/Downloads.html sometimes I wan...

How to print a raw file (print ready file) through USB port in MS Windows?
Hi, all: I have a print ready file (PCL or PS format) to send to a printer through USB port. But my platform is Win2k. Is there any method to directly send the job through USB port to the printer in Win2k? (just like "cat abc.ps > dev/usb/lp0" in linux) thanks for any advice, johny ...

How to print a raw file (print ready file) through USB port in MS Windows?
Hi, all: I have a print ready file (PCL or PS format) to send to a printer through USB port. But my platform is Win2k. Is there any method to directly send the job through USB port to the printer in Win2k? (just like "cat abc.ps > dev/usb/lp0" in linux) thanks for any advice, johny ...

How to print a raw file (print ready file) through USB port in MS Windows?
Hi, all: I have a print ready file (PCL or PS format) to send to a printer through USB port. But my platform is Win2k. Is there any method to directly send the job through USB port to the printer in Win2k? thanks for any advice, johny ...

Batch Files: Why is it the only the last line of the batch files is executing?
I am trying to write a batch file which changes some file attributes using chmod the batch file is as follows: chmod u+r, g+r o+r sample1.jsp chmod u+r, g+r o+r sample2.jsp chmod u+r, g+r o+r sample3.jsp chmod u+r, g+r o+r sample4.jsp When I run the batch file using the "sh" command, the only line which is executed is the last one. For the first 3 lines I receive the following error: chmod: Can't access sample1.jsp chmod: Can't access sample2.jsp chmod: Can't access sample3.jsp Any ideas on what is going on and how to correct this. I am a UNIX newbie. - jos=...

File, Find References, Copy Files: Truncating Long File Names
Hello All- I just experienced this behavior this morning. It was repeatable. Has anyone else seen this? The file Name was cut off after 57 characters. XP Pro SP2 2006 SP0 Office XP 2003 Pro Best Regards, Devon T. Sowell www.3-ddesignsolutions.com How long was the path name in total? Total including the file extension (.SLDASM) = 174. The file Extension was retained, just the Name was chopped off. These are my customer's files. Best Regards, Devon T. Sowell www.3-ddesignsolutions.com "TOP" <kellnerp@cbd.net> wrote in message news:1128364278.638472.150320@f14g2000...

batch file/jar file
hi guys,Is there an easier way of creating a batch file or jar archive filefor my programme so that it can execute without via j-Grasp(or e-Clipse)?I know how to use unix. is there may'be a unix way of doing it?-Thanks sihle87@gmail.com wrote: > hi guys, > > Is there an easier way of creating a batch file or jar archive file > for my programme so that it can execute without via j-Grasp(or e- > Clipse)? > > I know how to use unix. is there may'be a unix way of doing it? > > -Thanks Jar files can be made executable on both Windows and Linux. The exact met...

Copy files with a .vbs file
Hi Im a complete newbe at this and would like som help. Im sure this is very easy to do but i dont have any idea as where to start. I would like to have a .vbs file that i can click on to open e message box where I can specify a file. That file should then be copied 5 times and different text should be added infront of the original file name, like this: Org: 12324.txt Result: text1_1234.txt text2_1234.txt text3_1234.txt text4_1234.txt text5_1234.txt Anyone who can help me with this or point me in the right direction? Best regards Daniel -- ------------------------...

File IO/Copy A File
I am stumped on this one... Any easy way to copy a file from a button event in RB 5.2? I basically want the button to copy DB.rdb to DB.bak. THis way is someone hozes the file, we have a backup. Thanks in advance, SJ > I am stumped on this one... > > Any easy way to copy a file from a button event in RB 5.2? I > basically want the button to copy DB.rdb to DB.bak. THis way is > someone hozes the file, we have a backup. > > Thanks in advance, > > SJ Maybe I am missing what you are trying to do - but wouldn't FolderItem.CopyFileTo d...

Copying a file to another file
Hi, I wrote the following C program to copy a file to another file. #include <stdio.h> #include <stdlib.h> static FILE *open_file ( char *file, char *mode ) { FILE *fp = fopen ( file, mode ); if ( fp == NULL ) { perror ( "Unable to open file" ); exit ( EXIT_FAILURE ); } return fp; } int main ( int argc, char *argv[] ) { /* int ch;*/ FILE *from; FILE *to; char *buffer; long lSize; if ( argc != 3 ) { fprintf ( stderr, "Usage: %s <readfile1> <writefile2>\n", argv[0] ); exit (1);/* E...

drag and drop file over desktop shortcut on MS windows
Hello. I used drag&drop files feature for opening files by assigning app main = frame as a droptarget. It works fine after the frame is poped up. but when I = drop a file over the app's desktop shortcut, the file open is via shell = command line style ( app -f input-file-name ) defined at the app. Should I define the app as a droptarget for it ? thanks. ming =20 --------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org For additional commands, e-mail: wx-users-help@lists.wxwidgets.o...

Web resources about - Batch file operation copies files to desktop - comp.os.ms-windows.misc

Operation Gladio - Wikipedia, the free encyclopedia
Operation Gladio ( Italian : Operazione Gladio ) is the codename for a clandestine NATO " stay-behind " operation in Italy after World War II ...

Logan police set up school zone drink driving operation
Logan police step up operation targeting drink drivers in school zones after nabbing more drunk mums and dads than expected.

Resident of Wolseley Road, Point Piper, charged with running large drug operation
... in the country. But between the homes of models, barristers, judges and businessmen Eric James Jackson has been running a large drug operation, ...

Confessions of a Sydney surgeon: why your operation may not work
Commonly performed operations can be found to be useless, according to a practising Sydney surgeon.


Fusion Cues Up a VP of Digital Operations
... newest career chapter. Per Fusion chief digital officer Daniel Eilemberg , Mehta will be joining the company as vice president of digital operations. ...

Oberlin professor claims ISIS a 'CIA and Mossad operation'
Joy Karega, an assistant professor of rhetoric and composition at Oberlin College, let loose on Facebook with several unhinged posts about Israel ...

Medal of Honor recipient describes dramatic Taliban rescue operation
Navy SEAL Edward Byers received the Medal of Honor for his actions during a 2012 mission to rescue an American captive from the Taliban

Senvion To Launch Wind Energy Operations In India
... to an equity investment firm, Senvion is set to enter the wind energy market in India. Europe-based Senvion has announced plans to start operations ...

Inside a security operations center
... services provider Alert Logic reveals how proactive monitoring detects breaches and accelerates incident response Walk into a security operations ...

Resources last updated: 3/7/2016 11:17:43 AM