• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1672
  • Last Modified:

I have a batch file I would like to make more Professional.

Below is my batch file I would love to get in EXE or COM. I've tried many bat2exe or com programs but they all mess up the batch program or ignore echo. command (for space) and I believe all of them ignore the pause command completely.... I've also tried IEXPRESS that I found on XP.. that would be great.. but also didn't wait for user to press enter... and can't get it to do what I need.

Any suggestions?

Here is my batch

echo off
cls
title Big Stick Installation
echo.
echo.
echo.
echo.
echo Installing....
echo.
echo.
md c:\BigStick
md c:\BigStick\Backup
copy fix.bat c:\BigStick
copy BigStick.mde c:\BigStick\Backup
copy BigStick.ico c:\BigStick
copy BigStick.mde "C:\Documents and Settings\All Users\Desktop\BigStick.mde"
cls
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo Please refer to the Installation Manual to help guide you through this step.
echo.
echo.
echo.
echo.
echo.
pause
echo.

ACCESSRT.MSI
cls
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
pause
regedit.exe /s urs.reg
cls
echo.
echo.
echo.
echo You will now start your printer install,
echo PLEASE FOLLOW THE PRINTER INSTRUCTIONS IN THE MANUAL.(Steps 1-3)
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo When Windows has finished installing the drivers, you will be
echo returned to this window at which time you will press any key to continue.
echo.
echo.
Pause
cls
echo.
echo.
echo.
echo.
echo Rebooting your computer. This may take up to 2 min. PLEASE DONT PRESS ANY KEY.
echo.
echo.
sd.exe -r -t 01 -f
pause
echo on
0
detroitdr
Asked:
detroitdr
4 Solutions
 
matuseCommented:
You might want to look into making this an HTA (Html Application)  From there you could make a "splash screen" for your application with a button to "install" and maybe something like - click here for help, link to your website etc.  All of which would make your application appear much more professional.  

You can use VB scripts or windows Scripting host to perform the same tasks as are accomplished in this batch file.

Check out the following sites for some further resources:

http://www.pctools.com/guides/scripting/

Microsoft's HTA Helpomatic is also a good resource, get it here:
http://www.microsoft.com/downloads/details.aspx?FamilyId=231D8143-F21B-4707-B583-AE7B9152E6D9&displaylang=en 
0
 
BillDLCommented:
There's a couple of parts that you should maybe change in the batch file regardless of what you intend to do with it.

The command to call ACCESSRT.MSI is done without specifying any parameters.  A better way would be to call the program that is set to run the *.msi file type, and halt the batch process until it finishes by prefixing the command with START /wait, like this:

start /wait %SystemRoot%\system32\msiexec.exe /i %~dp0\accessrt.msi

In Windows XP, the %~dp0 variable holds the directory that the batch file was started from.
Msiexec.exe (The Windows Installer Tool) supports a number of switches by which you can dictate how it is run, including a forced reboot or a reboot only if required:

http://support.microsoft.com/kb/314881/EN-US/
http://msdn2.microsoft.com/en-us/library/aa367988.aspx

I would do the same with the Regedit command, eg:

start /wait %SystemRoot%\system32\regedit.exe /s %~dp0\urs.reg

That assumes "urs.reg" is in the same directory as the batch file, and not in C:\Windows\System32 folder along with regedit.exe, which would be the more usual scenario.

As an alternative to the Start /wait prefix, you can CALL a program.  This passes control out of the batch file to it, and when done control is returned back to the batch file.  The CALL prefix command is normally used to call other batch files.

You can also use the Windows XP variable %ALLUSERSPROFILE% instead of quoting C:\Documents and Settings\All Users, eg:

copy BigStick.mde %ALLUSERSPROFILE%\Desktop\BigStick.mde

There are a number of freeware and shareware programs that make it quite easy to compile your own customised installer where you can create your own info screens and prompts.

Probably the simplest method would be to build a self-extracting executable file (SFX package) that can be told to run a setup routine after it unpacks, like this:
http://www.gdgsoft.com/gsfx/index.aspx

You can do this in a more basic way using WinRAR to create a self-extracting *.exe file, but it's not as professional.

I've used this more advanced application from the same vendor, but you pay for the full version:
http://www.gdgsoft.com/pb/index.aspx

Creating, modifying, or deleting registry keys and values, copying files, etc, can also be done with *.INF files, and you can use IExpress to package them:

http://vlaurie.com/computers2/Articles/inf-file.htm
http://msdn2.microsoft.com/en-us/library/aa741215.aspx
http://msdn2.microsoft.com/en-us/library/ms790220.aspx
http://www.msfn.org/board/install_inf_file_command_line_t104891.html
http://www.dx21.com/SCRIPTING/RUNDLL32/INF.ASP
http://www.osronline.com/ddkx/install/create-inf_4l47.htm

Driver CD creators tend to use design programs like this to create CD Autorun interfaces from which Readme files can be launched and where the user can click on the appropriate button to install something or exit:
http://www.cdmenupro.com/index.htm
There are a lot of these type of programs about, and some are freeware:
http://www.tucows.com/software.html?t=706
I used to use AutoPlay Menu Studio, which was the previous version of the fully featured retail application:
http://www.indigorose.com/ams/

Hope this helps.
0
 
matrixnzCommented:
Hi detroitdr

InnoSetup is what you need, you'll find that this is one of the most commonly used programs for creating setup files.  Best of all it's free and very simple to use and wouldn't require alot of effort to create your script above.

http://www.jrsoftware.org/isinfo.php

Would recommend downloading the QuickStart Pack - http://files.jrsoftware.org/ispack/ispack-5.2.0.exe

If you install ISTools you get everything in Gui mode so you can see exactly your registry files that are run and also where files are installed.

As an example I've created the following for you to use, just Open ISTool then select Script and copy and paste the following, then save the file as BigStick.iss then click Project - Compile Setup this will create a BigStick.exe file whereever you saved the script.  Just double click to Run, to run silently just use -silent (progressbar) -verysilent (no progressbar).

Things to note:
The following script will try to copy the files from where ever you saved the script so if you save BigStick.exe to C:\Data then it will try to copy C:\Data\fix.bat to ... etc.. now if you'd rather just have the files compiled into the exe then just remove the external flag under the [Files] section.  You will still need to have the script at the root of where your files are so that when you compile it sees all your files.

The only other thing I've put in there is a method for you to install your printer silently without any user input if you don't wish this then just remove the following three lines and the entire Registry Section.

Filename: net; Parameters: stop spooler; Flags: runhidden skipifdoesntexist
Filename: net; Parameters: start spooler; Flags: runhidden skipifdoesntexist
Filename: rundll32; Parameters: "printui.dll,PrintUIEntry /if /b ""Printer Name"" /f {src}\Printer\RicohAP3200_Series\PCL6\oemsetup.inf /l {src}\Printer\RicohAP3200_Series\PCL6\ /r ""IP_192.168.1.2"" /m ""RICOH Aficio AP3200 PCL 6"" /z"; Flags: skipifdoesntexist runhidden

Anyhow hope that helps, if you have any queries feel free to ask.

Cheers

[Setup]
DefaultDirName={sd}\BigStick
OutputDir=.
OutputBaseFilename=BigStick
AppName=Big Stick Installation
AppVerName=Big Stick Installation 1.0
DisableDirPage=true
DisableFinishedPage=true
DisableReadyPage=true
Uninstallable=false
CreateUninstallRegKey=false
UpdateUninstallLogAppName=false
UsePreviousAppDir=false
AllowUNCPath=false
AppendDefaultDirName=true
UsePreviousUserInfo=false
DefaultUserInfoName=
DefaultUserInfoOrg=
DisableProgramGroupPage=true
UsePreviousGroup=false
AppendDefaultGroupName=false
AlwaysShowComponentsList=false
ShowComponentSizes=false
FlatComponentsList=false
UsePreviousSetupType=false
ShowLanguageDialog=no
LanguageDetectionMethod=none
TerminalServicesAware=false
AlwaysRestart=true
[Messages]
WelcomeLabel1=Welcome to the [name] Wizard
InstallingLabel=Please wait while files are being copied...
BeveledLabel=Big Stick Installation
StatusExtractFiles=Copying Files
SetupWindowTitle=Big Stick Installation Wizard
[Files]
Source: {src}\fix.bat; DestDir: {app}; Flags: external skipifsourcedoesntexist recursesubdirs
Source: {src}\BigStick.mde; DestDir: {app}\Backup\; Flags: external skipifsourcedoesntexist recursesubdirs
Source: {src}\BigStick.ico; DestDir: {app}; Flags: external skipifsourcedoesntexist recursesubdirs
Source: {src}\BigStick.mde; DestDir: {commondesktop}; Flags: external skipifsourcedoesntexist recursesubdirs
[Run]
Filename: {src}\ACCESSRT.MSI
Filename: net; Parameters: stop spooler; Flags: runhidden skipifdoesntexist
Filename: net; Parameters: start spooler; Flags: runhidden skipifdoesntexist
Filename: rundll32; Parameters: "printui.dll,PrintUIEntry /if /b ""Printer Name"" /f {src}\Printer\RicohAP3200_Series\PCL6\oemsetup.inf /l {src}\Printer\RicohAP3200_Series\PCL6\ /r ""IP_192.168.1.2"" /m ""RICOH Aficio AP3200 PCL 6"" /z"; Flags: skipifdoesntexist runhidden
[Registry]
Root: HKLM; SubKey: SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_192.168.1.2; ValueType: string; ValueName: HostName; ValueData:
Root: HKLM; SubKey: SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_192.168.1.2; ValueType: string; ValueName: HWAddress; ValueData:
Root: HKLM; SubKey: SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_192.168.1.2; ValueType: string; ValueName: IPAddress; ValueData: 192.168.1.2
Root: HKLM; SubKey: SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_192.168.1.2; ValueType: dword; ValueName: PortNumber; ValueData: $0000238c
Root: HKLM; SubKey: SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_192.168.1.2; ValueType: dword; ValueName: Protocol; ValueData: $00000001
Root: HKLM; SubKey: SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_192.168.1.2; ValueType: string; ValueName: SNMP Community; ValueData:
Root: HKLM; SubKey: SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_192.168.1.2; ValueType: dword; ValueName: SNMP Enabled; ValueData: $00000000
Root: HKLM; SubKey: SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_192.168.1.2; ValueType: dword; ValueName: SNMP Index; ValueData: $00000001
Root: HKLM; SubKey: SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_192.168.1.2; ValueType: dword; ValueName: Version; ValueData: $00000001
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
detroitdrAuthor Commented:
thank-you to all.

Question for Bill
"In Windows XP, the %~dp0 variable holds the directory that the batch file was started from."
-What about Win2000?
0
 
BillDLCommented:
Hi detroitdr.

%0 holds the name of the batch file when run.
%1 holds the full path to, and filename of your batch file when it runs.
%2 to %9 hold whatever other parameters were passed to the batch file if it was called from elsewhere.
~ is used as a modifier

"Modifiers use current drive and directory information to expand the batch parameter as a partial or complete file or directory name".

%~dp0 therefore expands the %0 variable to the Drive Letter and Path of the batch file name, but without an f in there it excludes the file name.

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/percent.mspx

Try this in a *.cmd or *.bat file to demonstrate:

@echo off
echo.
echo percent ~ f zero equals
echo %~f0
echo.
echo percent ~ zero equals
echo %~d0
echo.
echo percent ~ p zero equals
echo %~p0
echo.
echo percent ~ d p zero equals
echo %~dp0
echo.
pause
exit

This is all true of Windows 2000 CMD.EXE also:
See:
http://www.microsoft.com/technet/prodtechnol/Windows2000serv/support/FAQW2KCP.mspx
and expand the question entitled: "Q. How do I parse a file name parameter into its' constituent parts?"

Bill

0
 
KromptonCommented:
Another option for you is AutoIt. A freeware scripting tool that is reasonably easy to jump into without too much of a learning curve. It also allows you to compile your scripts into an exe once you get them working the way you want. If you have the time or inclination you can also develop some fairly professional looking scripts.
0
 
BillDLCommented:
Thank you detroitdr
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now