Help for batch command.

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Cruvenium

Thread Starter
Joined
Jul 23, 2009
Messages
12
Hi,

I'm creating a disc which consist of a runnable exe, and a batch file.

I need that when people double click the batch file, it copies 2 dlls over to the installed program folder.

I figured out different people have different program folders, example some are C:\ some are D:\, some have Program Files (x86) some do not.

How do I specify in the batch file to copy this two dlls (which are inside the CD) to copy to the installed folder of the program?

P.S I don't mind if it's in JavaScript, as long as it's the same function.
 

Squashman

Retired Trusted Advisor
Joined
Apr 4, 2003
Messages
19,786
You really didn't need to bump your thread. It was no more than 2 down from the top when you bumped it.

You are either going to have to know all the possible paths and then do an IF statement to see if that folder structure exists or there would have to be some common file that exists in that folder that you would basically have to search for on the entire hard drive or any other hard drives considering you are saying that it is not installed on the system partition. Once the file is found you can extract the path with the cmd extensions in a for loop.
 
Joined
Aug 7, 2007
Messages
9,028
Use the environment variable %ProgramFiles% to find the Program Files folder.
The Program Files(x86) folder will only exist on 64 bit versions of Windows, and has it's own environment variable (%ProgramFiles(x86)%) so you can check to see if it exists first:

Code:
If Defined %ProgramFiles(x86)% (
Copy X:\First.dll "%ProgramFiles(x86)%\MyProgram"
Copy X:\second.dll "%ProgramFiles(x86)%\MyProgram"
) Else (
Copy X:\First.dll "%ProgramFiles%\MyProgram"
Copy X:\second.dll "%ProgramFiles%\MyProgram"
)
Note that on Vista/Win7, the batch file will have to be run from an Elevated Command Prompt, so you will need to create a shortcut to the batch file for then to click instead of the batch file itself, and set the shortcut properties to Run as Administrator:

  • Right click the shortcut, click Properties
  • Click the Shortcut tab
  • Click the Advanced button
  • Check the Run as Administrator box ( On XP it says Run with different credentials)
You can use the same shortcut for XP and for Vista/Win7, but it will prompt XP users to use the Current User, or to select a different user. Vista will bring up a UAC prompt.

So you need to provide some instructions for XP users to use the current user credentials, or create two shortcuts, one for XP and one for Vista/Win7
 

Squashman

Retired Trusted Advisor
Joined
Apr 4, 2003
Messages
19,786
Good call Jerry. Totally forgot about the environmental variable. Lets hope the program folder name is the same!
 
Joined
Sep 19, 2009
Messages
3
The batch command is a recovery console command that executes a series of commands within a file. Executes commands specified in a text file.
BATCH Inputfile [Outputfile]....Batch cannot be one of the commands included in the Inputfile. Examples:

In the above example, the batch command would run through each of the commands in the myfile.txt file and display the output to the screen.... I have information regarding Batch command so i want to share that with you....
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top