kwatt562
asked on
Run Program from bat file
Hi I have a program that I want to install with some switches. I want to run the program the network.
"\\servername\dist$\Commer cial Applications\OSGeo4W\osgeo 4w-setup-x 86.exe" -d -q -L -R c:\OSGeo4w -l "\\servername\dist$\Commer cial Applications\OSGeo4W\http% 3a%2f%2fdo wnload.osg eo.org%2fo sgeo4w%2f\ x86\releas e"
When I run it doesn't complete, however when I map a drive to the path and run
osgeo4w-setup-x86.exe -d -q -L -R c:\OSGeo4w -l "\\servername\dist$\Commer cial Applications\OSGeo4W\http% 3a%2f%2fdo wnload.osg eo.org%2fo sgeo4w%2f\ x86\releas e"
from command line it works perfectly, so I think its my understanding of how batch files work?
"\\servername\dist$\Commer
When I run it doesn't complete, however when I map a drive to the path and run
osgeo4w-setup-x86.exe -d -q -L -R c:\OSGeo4w -l "\\servername\dist$\Commer
from command line it works perfectly, so I think its my understanding of how batch files work?
do you need any login credentials for the shared network folder?! if yes, you'd have to pass them, too...
ASKER
Hi, thanks, I am running as full domain admin with access to the PC and network
When I run it doesn't completeWhat do you mean with by that?! Any messages and/or errors?! Do you run it from command prompt or do you have a batch file?! If yes, it would be nice, if you could provide the batch file(s)...
ASKER
It starts the installation then stops, within 1-2s, no errors or logs, I can then run immediately via command prompt (as above) and it completes the installation. sorry the first part in the question is the batch file, the second part is how I run it from command prompt (which works ok - when mapping a drive to the .exe file)
To start a program and then close command prompt without waiting for program to exit:
start /d "path" file.exe
Maybe you give it a try. Nevertheless, a workaround would be to connect to the shared folder via a temporary "net use", that would be deleted right after setup has completed...
I suggest you change "start /d" with "start /w" as your batch script should have to wait for completion for the exe call...
ASKER
If I understand correctly
start /W "\\servername\dist$\Commer cial Applications\OSGeo4W\" osgeo4w-setup-x86.exe -d -q -L -R c:\OSGeo4w -l "\\servername\dist$\Commer cial Applications\OSGeo4W\http% 3a%2f%2fdo wnload.osg eo.org%2fo sgeo4w%2f\ x86\releas e"
Is that right?
I tested, it starts the installer and then says "cannot find '-d'. Make sure you typed the name correctly, and then try again.""
start /W "\\servername\dist$\Commer
Is that right?
I tested, it starts the installer and then says "cannot find '-d'. Make sure you typed the name correctly, and then try again.""
"path" is the working/starting directory, heres some kind of reference:
http://ss64.com/nt/start.html
so it would rather be something like this:
http://ss64.com/nt/start.html
so it would rather be something like this:
start /W "" "\\servername\dist$\Commercial Applications\OSGeo4W\osgeo4w-setup-x86.exe" "-d -q -L -R c:\OSGeo4w -l \\servername\dist$\Commercial Applications\OSGeo4W\http%3a%2f%2fdownload.osgeo.org%2fosgeo4w%2f\x86\release"
It is quite possible the installer tries to look into the current directory from other files when it is run from the UNC path the current directory will be c:\windows\system32 or wherver the batch file is. I would suggest using:
@echo off
pushd "\\servername\dist$\Commer cial Applications\OSGeo4W"
osgeo4w-setup-x86.exe" -d -q -L -R c:\OSGeo4w -l "\\servername\dist$\Commer cial Applications\OSGeo4W\http% 3a%2f%2fdo wnload.osg eo.org%2fo sgeo4w%2f\ x86\releas e"
popd
The pushd will map a temporary drive to unc listed and then change to that as the current dir. popd removes it afterwards.
Steve
@echo off
pushd "\\servername\dist$\Commer
osgeo4w-setup-x86.exe" -d -q -L -R c:\OSGeo4w -l "\\servername\dist$\Commer
popd
The pushd will map a temporary drive to unc listed and then change to that as the current dir. popd removes it afterwards.
Steve
ASKER
thanks everyone, the last two posts do the following
I don't get any errors, the exe runs (as I am prompted by UAC) then it just stops immediately
I don't get any errors, the exe runs (as I am prompted by UAC) then it just stops immediately
ASKER
It has created the folder OSGeo4w in the root of C and there is some files there also some start menu programs, but hasn't installed the packages from \\servername\dist$\Commerc ial Applications\OSGeo4W\http% 3a%2f%2fdo wnload.osg eo.org%2fo sgeo4w%2f\ x86\releas e
Oh hang on I didn't look at your option here:
http%3a%2f%2fdownload.osge o.org%2fos geo4w%2f\x 86\release
Do the %'s need to be passed through? % is a special character in command. You should try if possible to put it back to proper characters, i.e.
@echo off
pushd "\\servername\dist$\Commer cial Applications\OSGeo4W"
osgeo4w-setup-x86.exe" -d -q -L -R c:\OSGeo4w -l "\\servername\dist$\Commer cial Applications\OSGeo4W\http://download.osgeo.org/osgeo4w/\x86\release"
popd
If it needs those characters in there we can escape them with using %% in place of each %
Steve
http%3a%2f%2fdownload.osge
Do the %'s need to be passed through? % is a special character in command. You should try if possible to put it back to proper characters, i.e.
@echo off
pushd "\\servername\dist$\Commer
osgeo4w-setup-x86.exe" -d -q -L -R c:\OSGeo4w -l "\\servername\dist$\Commer
popd
If it needs those characters in there we can escape them with using %% in place of each %
Steve
ASKER
I doubled the % symbols, seems to work better (in that the installer is running) but its asking questions (not silent) not sure why, will review and revert
thanks!
thanks!
OK, suggest launch a command prompt, run the pushd command to get the drive mapping, then try the command manually typed and see how it works silently or not for starters.
Ask if need any more pointers, don't forget to accept answers when done.
Steve
Ask if need any more pointers, don't forget to accept answers when done.
Steve
ASKER
OK I got it to work
net use Z: "\\server\dist$\Commercial Applications\OSGeo4W"
start /W Z:\osgeo4w-setup-x86.exe -d -q --local-install -root c:\OSGeo4w -l "\\server\dist$\Commercial Applications\OSGeo4W\http% %3a%%2f%%2 fdownload. osgeo.org% %2fosgeo4w %%2f\x86\r elease"
When I use net use and add the double %% it works, might be a spaces issue, but not sure when to add the quotes.
The only issue is that it leaves the drive mapped, tried adding net use Z: /delete but it ignores the command
net use Z: "\\server\dist$\Commercial
start /W Z:\osgeo4w-setup-x86.exe -d -q --local-install -root c:\OSGeo4w -l "\\server\dist$\Commercial
When I use net use and add the double %% it works, might be a spaces issue, but not sure when to add the quotes.
The only issue is that it leaves the drive mapped, tried adding net use Z: /delete but it ignores the command
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
got it too work with
pushd \\serverdist$\Commercial Applications\OSGeo4W\
start /W osgeo4w-setup-x86.exe -d -q --local-install -root c:\OSGeo4w -l "\\server\dist$\Commercial Applications\OSGeo4W\http% %3a%%2f%%2 fdownload. osgeo.org% %2fosgeo4w %%2f\x86\r elease"
popd
thanks!!
pushd \\serverdist$\Commercial Applications\OSGeo4W\
start /W osgeo4w-setup-x86.exe -d -q --local-install -root c:\OSGeo4w -l "\\server\dist$\Commercial
popd
thanks!!
No problem, glad we got there in the end!