How to create bat file to publish to a web server.

Hi All,

I used to work with a guy that showed me how to set this up before, but don't remember how to do it.  Basically, he created a .bat file called Publish and somehow inserted it in the "right click" menu.  So, when I was done working on a file I could right click on the file on my development server and it would transfer the file to the production server.  It the file already existed on the production server, it would overwrite it.  Here is the code from that publish.bat file:

@if not exist "F:%~p1" mkdir "F:%~p1"
@for /f "tokens=*" %%a in ('dir %1 /b') do @copy %1 "F:%~p1\%%a"

Here is my problem... this does not work and I don't remember how to put it in the right click menu.  On my current laptop... my development server is mapped drive of Z: and my production server is a mapped drive of O:.  So, here is the order of things that I need to happen.  I am using my laptop to connect to my development project via VS.net.  I would like to be able to have a windows explorer window open displaying the files on my development box.  I would like to right click on any file in that dialogue box and click on publish and a copy of that file would be put on the production server.

Any help would be great.

Thx,

Muligan
muliganAsked:
Who is Participating?
 
jrs_50Commented:
As I said earlier:

@if not exist "O:%~p1" mkdir "O:%~p1"
@for /f "tokens=*" %%a in ('dir %1 /b') do @copy %1 "O:%~p1\%%a"

or possibly

@if not exist "O:%~p1" mkdir "O:%~p1"
@for /f "tokens=*" %%a in ('dir Z:%1 /b') do @copy %1 "O:%~p1\%%a"

first line checks for existence of directory on O and creates if it does not exist

second line loops through the file names (top=using default, bottom specifically Z) and copies the files to O.


0
 
jrs_50Commented:
It would appear that the bat file presumes the current default drive and directory as the source and copies to the F: drive.  You might try changing the F: to Z:    You might also need to be more specific regarding the source file drive and directory.  As for putting the bat file on the menu try right-clik on the bat to create the applicable short cut.  Then, presuming it is not prevented, move the shortcut to the applicable menu.

0
 
SStoryCommented:
Open notepad, copy the following to it, then save as c:\publish.reg
run that file, then you can delete it after it adds to the registry.  This will offer the menu item "Publish" when you right click any file and will pass that to publish.bat

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Publish]

[HKEY_CLASSES_ROOT\*\shell\Publish\command]
@="publish.bat %1"

Hope this helps.  

You are assuming drive F:

0
 
muliganAuthor Commented:
Thanks SStory.... that did place the Publish in my right menu.  But the file transfer did not work.  My development server is mapped drive of Z: and my production server is a mapped drive of O:.  So, I need to transfer the files from z to o.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.