3:07 PM
let me know when someone is here
 
I am here for all your DOS CMD needs!
 
lol great
I'm looking for a way to copy a file from a server to a remote host
using a batch file
any suggestions?
 
ok how remote, is it on the same network?
 
ah, more DOS BATCH file fans enter
 
3:11 PM
I will have the IP address of the machine
 
can you blame them really?
 
I happen to like scripting my build environments ;)
 
not at all
 
what about permissions? What OS?
 
the permissions seems to be the problem I'm running into right now. and XP
 
3:12 PM
What server are you starting from? OS etc?
 
so far I've got a copy command but then it fails due to username and password authentication failure
so I need to either be able to enter the network admin username and password or bypass having to enter that entirly
sorry windows server 2003 standard edition
 
and the target system?
 
ok, so from server to xp ... are they on the same domain?
 
3:15 PM
it's all about the identity of the process doing the copy, so what you want to think about is, "under what user is this copy being done?"
 
@JeffAtwood you beat me to it
 
the server admin user
 
so then that server admin user needs rights to the target XP box
 
I think once you get it setup you can set the command to run as network service or something in the permissions or something, I would really have to refer you over to the SF folks for this to make sure it's all cosied up on the permissions issues.
How are you going to schedule the task? In "Windows Tasks"?
Or will you be using a third party application?
 
yeah windows tasks lets you set the identity of the "user" running the task for example
 
3:16 PM
Are you just going to use the "copy" command from Windows?
@JeffAtwood Exactly, but a third party app might not.
 
its going to be initiated from a host clicked webbrowser button
 
like an asp.net page?
 
kinda, I'm using visual foxweb/foxpro
 
Oy, I'm not sure what that runs on ... does that get hosted on IIS?
 
I'm sorry, IIS?
 
3:18 PM
visual foxweb is a thing?
 
lol
believe it or not, it is
 
@JeffAtwood Are you thinking what I'm thinking? "Ouch" is the first thing that comes to mind.
 
well you need to figure out what IIS process identity visual foxweb is running under
 
yea yea, It was the legacy programming language when I started this job, that being said, lets return to my issue of finding the correct DOS command
 
I'm guessing it's still a regular IIS app pool
 
3:20 PM
@sadmicrowave IIS in general can be run as a Network Service or as another user, and if you're using IIS7 can be setup to run individual app-pools as specific users (ok, so I admit I love IIS7 way more than IIS6) and the app-pool can be assigned to the app in specific
 
I think you can use foxpro code running on the page to initiate the file copy
 
Point being, shell commands spawned under a thread tend to run with the same privileges as the issuing thread
alternately, just use foxpro ... dammit Jeff! :p
or should I q:
 
I mean have you tried doing this already @sadmicrowave ?
like you could get a test page that copies a file from one place on the server to another place on the server.. then you know it's working and can extend it to "copy this file over the network"
because the permissions will bite you, most likely, when you start trying to copy over the network to another machine
 
I can copy the files over with foxpro, the issue is that I cannot run them on the remote host using foxpro, so the idea is that I would create a batch file that would copy and then run the files
 
oooooooh
that's totally different
 
3:23 PM
wait yeah why are we running files?
 
Are you copying executables?
or are you processing files?
 
this story just gets crazier
 
the best thing to do is to push the files to a directory on the target machine from the server
then the server stops doing anything at all
 
lmao, yes, executables and other things too
 
then the client has a process setup with a FileSystemWatcher that reads that directory for new files
then it processes the new file as a service on the target machine
 
3:24 PM
thats fine and dandy but then I cant get the files to run
 
because you're not using a service with a FSW
 
hmmm
 
And how do you know the files are safe and sane to run?
Also, in the future, you might want to stackoverflow.com/questions/how-to-ask because this:
 
because they are my files
 
15 mins ago, by sadmicrowave
I'm looking for a way to copy a file from a server to a remote host
doesn't say "copy and run the file on a target system"
 
3:25 PM
wait, I have a diagram of how this system will work
 
well I didnt say anything about running them because I was trying to accomplish 1 thing at a time
 
@sadmicrowave Yeah, you need to run a service with FSW on the target machine, or a service of some sort, that you can use to activate the client software
 
that diagram seems like it will work to me
lmao
 
@JeffAtwood ;) lol
 
starting to sound like I should get into a visual foxpro/foxweb room and see how to execute files remotely
 
3:27 PM
@sadmicrowave so do you get the concepts in play here? Push a file, process it. Two activities, two processes.
 
yes I understand that
the processing the file is the part I don't know how to do yet
 
@sadmicrowave or you could ignore the advice of seasoned programmers and just kinda do whatever... except there's no really solid "how to execute files remotely" that doesn't involve a timer'd task or explicit domain privileges, and two processes is insanely easier to setup
 
usually when I did stuff like this there was a "monitoring" process on the other end waiting for files to arrive, and it would do something
 
@sadmicrowave Do you write any C# or VB.NET?
@JeffAtwood FileSystemWatcher no?
 
I don't think there's any way to do this without pre-installing some kind of monitor on the Windows XP machine
 
3:29 PM
@JeffAtwood well yeah, hence the "service" I referred to earlier, like a for real windows service
 
not ghetto enough
 
Hello Jeff
 
you could set up a scheduled task on the XP machine to do the monitoring
I can't remember what XP has in that area
 
It has Windows Tasks
I bet the ServerFault guys could do a better job helping him tho
 
but I don't know when the user is going to click the button, so the scheduled task would have to run, like every 5 seconds
 
3:31 PM
I think at this point I would be asking "what is your goal, what do you want to accomplish" -- explain THAT to us first
forget HOW
 
Maybe in the form of a SO question?
 
just tell us what it is you want to ultimately achieve
 
@JeffAtwood @sadmicrowave and we'll help you figure out the how
 
pretend it can all be done magically somehow and concentrate on the "what is it you want to end up with"
 
the user clicks a button in the webbrowser. The webserver then copies over certain files to the host machine and runs them
done
 
3:32 PM
right but WHY
 
define "runs them" ... what will the running do
 
what are these files we are running
what is their purpose
like what is the business function, why are we being paid to do this, what work is being accomplished
 
these are vb forms and vfp forms that need to open for the user to input test console data
 
ok now why wouldn't that data be entered in say a web form on the web page?
 
So someone will be sitting at a desk waiting on a user to do something on the web, then this box will pop up to the user at the desk?
 
3:33 PM
@Jeff
 
@sadmicrowave Why aren't you happy?
 
probably because he has to build this rube goldberg machine
 
lmao
 
@JeffAtwood because at this point its a time problem, we have a deadline to make this process work, and the time frame is too short to convert hundreds of highlyl specialized forms to web applications
 
so why can't the user run the app from a network share? why this weird "push a button on a web form and then copy it to their machine" thing?
 
3:35 PM
because these forms will not open on the host machine being run over the network. They must be resident on the local machine to run
 
@sadmicrowave so is the timeline short enough that you can't afford to get it right in the first place? You're having a hard time explaining the business logic of why you want to copy files and run them. I'm curious what the user at his desk experiences when this form just pops up
 
I don't think there are any permissions issues when running .exes from network shares particularly on older OSes
ok, so how about this: the user clicks on a batch file on a network share which copies the files over and then runs it
 
@JeffAtwood there are limitations from Windows on opening network file "sockets"(??) in a short period of time.
 
as said before, only some of them are .exes, other are vb and vfp forms
 
I think a batch file would work, why do we need the "go to a web page and click the button" part?
 
3:37 PM
wth mate, don't vb or vfp forms turn into exes before the end-user sees them?
@JeffAtwood I saw it as two distinct entities, one being surprised by a new window popping up
 
no
We dont really give a sh** if the user is 'surprised' that the external window pops up, just so long that they have the tools in front of them to do their damn job
 
ok fine
 
now I feel like we're getting somewhere.
what is their "damn job" when these files pop up, and why are they popping up?
 
but could they click on the batch file on a network share, which would copy the files over and then run them?
eg can we skip the "web page" part of this?
 
If I was making that for public use (non-internal) I would care greatly about curb-appeal and surprises to the user....but that is not the case here
 
3:40 PM
@JeffAtwood indeed. I'm curious what the web-aspect is to this at all
 
or the web page could give them the URL which was a filesystem URL to a network path
 
no, we cannot skip the webpage
 
see I don't understand that part
you can construct URLs which are filesystem and network paths
 
the web-aspect is important because I've developed an online instruction manual type of application that gives them what procedures to step through depending on what part number they are building or testing....therefore, when the are testing a certain part number and they click a test form button the proper form must come up to enter data for the test consoles to actually work
 
ah that helps
 
3:42 PM
so they'll be using the webpage from their computer?
 
ok so then that webpage could contain a URL to a batch file, eg a filesystem URL
 
said same computer that will be running the app at the end of the convoluted process?
@JeffAtwood exactly my thought
 
YES!!!!
 
file://server/share/batch-process-1235234523423423423.bat
clickety spickety and run the given file.
 
3:44 PM
yeah so the batchfile could run, but you'd need to test this in browsers.. might work ok with the whole IE "local network zone" security
 
so why do you need to copy it to the machine? That's the part that we're having an issue with... why not run it from the network?
 
it has to be local he said
 
yes thank you!!!!! now we are finally back to my original question....how can i copy [and run] files from a server to a host using a batch file
 
@sadmicrowave ok but you're doing it backwards
 
how so?
 
3:45 PM
ok so in this case the XP user is the identity of the copy
 
you don't need the server to push if they're already on the network and on the client, you need the client to pull and run
@JeffAtwood yep
 
thats fine, if we want to do it that way...i just figured it would be easier to have the webserver do it considering it is already receiving and processing the 'click' action from the user
why not have it do acouple more things
but whatever, I'm always open to new ideas
 
because your way is more convoluted than my way?
 
alright, why don't you explain how your way will work
 
I did.
 
3:47 PM
you explained the concept that the host pulls from the server then runs......but how do I code that?
 
in a dos batch file...
consider how would you get it over now ... enumerate those steps
 
this might be a good time for this chat room to finally enter into some code syntax sharing
 
do you need to create a new directory on localXP?
 
<div class="divclass" onclick="myFunction()";></div>

function myFunction();
{
//How do I get the element ID that called this? Do I pass it as a parameter in the function or can I use "this" keyword?
}
 
3:48 PM
@sadmicrowave WRONG. You're coding wrong. You never write code without specs.
@MALON that sounds like a javascript or asp.net question, not dos commands
 
haaaaaaaaaaaaa i went to thew rong chat
didn't even notice, sorry
 
do you need to delete any existing files in the directory before you begin processing?
will the file location change based on the particular file you need to work with? For instance, will the VB form move to a new part of the server based on input commands?
 
what woulld be easier? overriding the existing file (if the same files are being copied) or just deleting all and starting again for every click
??
 
It's not my business process, I can't say.
what do you want to have happen?
see where these are specs that you have to define before you write the first line of batch file?
 
3:50 PM
just override
 
I personally would opt for delete * because it's easier to script.
less room for errors
 
wtf, thats why I asked you....so lets go with delete
 
next, what other files are you copying over. Just the form.vb? a whole project?
 
lets just start with a vb form then we will get into multiple files
 
@sadmicrowave ah but you're not reading my questions and following my thread. It's your project, these are things I would've already considered and written a basic plan on how to attack it. I can't tell you what to do, I can only say what I would do.
so then the file would look like: (let me type)
REM file://server/share/blahblahblah.bat
REM path of above file
c:
cd /testdir
REM I don't know that the following command is syntactically accurate,
REM this is batch pseudocode
delete *.* /s /y

REM now that the dir is empty, copy the remote files over
copy //server/share/files/form.vb .

REM now that the files are local, execute them
vs ./form.vb
the file should be both self contained and should have the info about where to find the file That's the point of the URL at the top of the file
if this were a unix-like system then it would probably start off #!/bin/perl or whatever
 
3:56 PM
alright, so this is the batch that the local host will run after they click in the webbrowser
??
 
specific to the file on the server that you want
they're easy enough to script out once you define what you want to happen, so you create them from a db script on the server.
 
right right, my next question is going to be...how do I get this batch file to execute on the local host after the click?
 
or create it on the server and when the server posts back to the client you send a redirect to the URL after you create it
@sadmicrowave ... ... seriously? ... ... will there be any sort of user at the terminal?
 
ok, which then comes up with a "save", "cancel" dialog box....
 
then you get them to save and run, this becomes a training issue.
and before you say "well what if they cancel the command" ... well what if they do. I can't make a technological system FORCE human behavior. Only training can coerce human behavior
if you want it to be automated then you MUST write a "Windows Service" to be installed on each client. End. Of. Story.
(note that each service does not need to be hand coded, one is the same for each system)
 
4:00 PM
alright I see what youre saying....but I'm trying to diminish the possibility of screw ups....If the user downloads the file then has to go find it and click it we run the risk of the user going to the wrong directory, clicking the wrong file....blah blah blah...which is why I needed a way to have the form auto execute
 
@sadmicrowave then you will have to write a (fill in the blank) __________________
 
hmm...that sounds alot like the help I was looking for when I started the room
how to write an app to do just that in a batch file form....
 
I can see I'm not making headway
you can't do that
You ever listen to any comedians? Ever hear one use the routine "you can't get there from here"?
There's EITHER a) batch file executed by client OR b) service
you have to have something on the remote machine that starts the executable on the remote machine
 
all you are doing is restating exactly what I already know and why I needed help in the first place....
 
I really really really suggest you write a question on SO that details "I have a server, with a web interface, that I need the user to interact with, and let them eventually have a set of files end up on their machine, that gets run on their machine"
@sadmicrowave apparently not
and then let us migrate the question for you to ServerFault where they can help you figure out the permissions and whatnot to get the files to run via batch, or they can recommend an out of the box tool for you
 
4:04 PM
you are saying that what I want, cannot be auto executing using a batch file and I need to create an app to do it using another language
or some sort of service
 
OR we can start finding you help on how to write a FileSystemWatcher type service
@sadmicrowave yes, that is what I am saying
and if you can prove me wrong otherwise, WITHOUT ASKING AN IT ADMIN SUCH AS EXISTS ON SERVERFAULT, then I am open to hearing it.
And you'll notice I've mentioned you going to SF for help on this like 1000 times because that's what they do over there. This site is about writing code. Not running networks and dealing with remote execution of batch files.
 
well, that concludes (after a huge headache) the extent of my reason to be in this room
thanks for your hlep
 
They have more experience with that.
I look forward to your SO question