PDA

View Full Version : Script



Micks
28-06-2013, 07:53 AM
Have a program I would like to silently install though would like the ability to install from it's own Dir without the need to specify it path or location for install?

If I install from the root of C installs no problem.
Manufacturer recommends installing as eg
C:\"Mick.exe" /s /v"SERIAL=000000000000" -f1"C:\setup.iss"

Any pointers from any scripting dudes is appreciated?

Micks
28-06-2013, 10:16 AM
This is what I'd like to use but not working:

"%~dp0Mick.EXE" /s /v"SERIAL=000000000000" -f1"%~dp0setup.ISS"

QldKev
28-06-2013, 10:27 AM
When you say not working, why? Are you getting an error message?

Micks
28-06-2013, 10:37 AM
When you say not working, why? Are you getting an error message?

Yeah Kev comes up in Cmd prompt "Mick.exe not recognized as an internal or external command, operable Prog. or batch file".

Trying to have install from a temp Dir instead of a Network location or Root drive.
It does install perfectly with code in 1st post.

Rate
28-06-2013, 08:21 PM
Hi Mick,

At a very quick glance, it looks like when you're trying to call the executable, Windows can't find it.

This could be due to a couple of reasons. Is the batch file you're running located in the same directory as Mick.exe?
I haven't done a lot of Windows scripting, but I think %~dp0 refers to the directory and path of the executing script file... so if Mick.exe is not in the same directory, it won't find it.

Some options to consider:
- in the actual script, change directory to the location of Mick.exe before calling it
- again in the script, modify the path environment variable to include the directory where Mick.exe is located

I hope that gives you some ideas...

SimonNQ
28-06-2013, 11:09 PM
The %~dp0 is passing the current directory of the bat file you just ran, you are then looking for a prohram called Mick.exe within that same directory. Same for your setup.iss file.

So,
if you executed the bat file from C:\Scripts your command above would read

"C:\Scripts\Mick.EXE" /s /v"SERIAL=000000000000" -f1"C:\Scripts\setup.ISS"

This will fail unless both Mick.exe and Setup.iss are both located in the C:\Scripts\ directory.

jc_sv8
28-06-2013, 11:38 PM
Usually most programs always unzip/deploy into the temp directory.

You can use the system variable TEMP or TMP depending on where it was ported from (MS or Unix)

In your script you can use mkdir %TEMP%\mydir to copy all of your files to your newly created mydir.
Reference everything from that point and you don't need to create any directory paths or environment variables and all should be good.

Micks
29-06-2013, 07:19 AM
Ok Guys very big thanks to Rate, Simon & JC the explanations that nailed it!:goodjob::thumbsup::thumbsup:
Figured out I was trying to run the script by Elev Cmd prompt when I should have run it from a batch!
All working good now. Just have to taskill the opening page of the prog to make it totally silent.
Thanks again Mick