Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Run Program from bat file

Posted on 2014-01-09
18
Medium Priority
?
935 Views
Last Modified: 2014-01-14
Hi I have a program that I want to install with some switches. I want to run the program the network.

"\\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"

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$\Commercial Applications\OSGeo4W\http%3a%2f%2fdownload.osgeo.org%2fosgeo4w%2f\x86\release"

from command line it works perfectly, so I think its my understanding of how batch files work?
0
Comment
Question by:kwatt562
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
  • 5
18 Comments
 
LVL 14

Expert Comment

by:Alexander Eßer [Alex140181]
ID: 39768044
do you need any login credentials for the shared network folder?! if yes, you'd have to pass them, too...
0
 

Author Comment

by:kwatt562
ID: 39768057
Hi, thanks, I am running as full domain admin with access to the PC and network
0
 
LVL 14

Expert Comment

by:Alexander Eßer [Alex140181]
ID: 39768068
When I run it doesn't complete
What 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)...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:kwatt562
ID: 39768092
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)
0
 
LVL 14

Expert Comment

by:Alexander Eßer [Alex140181]
ID: 39768125

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...
0
 
LVL 14

Expert Comment

by:Alexander Eßer [Alex140181]
ID: 39768135
I suggest you change "start /d" with "start /w" as your batch script should have to wait for completion for the exe call...
0
 

Author Comment

by:kwatt562
ID: 39768158
If I understand correctly
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"

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.""
0
 
LVL 14

Expert Comment

by:Alexander Eßer [Alex140181]
ID: 39768309
"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:
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"

Open in new window

0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39768352
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$\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"
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
0
 

Author Comment

by:kwatt562
ID: 39768377
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
0
 

Author Comment

by:kwatt562
ID: 39768415
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$\Commercial Applications\OSGeo4W\http%3a%2f%2fdownload.osgeo.org%2fosgeo4w%2f\x86\release
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39768496
Oh hang on I didn't look at your option here:

http%3a%2f%2fdownload.osgeo.org%2fosgeo4w%2f\x86\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$\Commercial Applications\OSGeo4W"
osgeo4w-setup-x86.exe" -d -q -L -R c:\OSGeo4w -l "\\servername\dist$\Commercial 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
0
 

Author Comment

by:kwatt562
ID: 39776035
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!
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39777191
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
0
 

Author Comment

by:kwatt562
ID: 39779159
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%%2fdownload.osgeo.org%%2fosgeo4w%%2f\x86\release"

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
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 2000 total points
ID: 39779445
Use pushd / popd ... they map and the popd removes.  Yes when there is a space in the path with net use you will need " ".

you shouldn't need start /w ... all that does is start the exe and wait, you might aswell just put the exe name?

So it was the % being processed mainly then by the sounds as I suggested.

Steve
0
 

Author Comment

by:kwatt562
ID: 39779482
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%%2fdownload.osgeo.org%%2fosgeo4w%%2f\x86\release"
popd


thanks!!
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39779590
No problem, glad we got there in the end!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question