Tech Support Guy banner
Status
Not open for further replies.
1 - 6 of 6 Posts

·
Registered
Joined
·
12 Posts
Discussion Starter · #1 ·
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.
 

·
Retired Trusted Advisor
Joined
·
19,786 Posts
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.
 

·
Registered
Joined
·
9,026 Posts
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
 

·
Registered
Joined
·
3 Posts
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....
 
1 - 6 of 6 Posts
Status
Not open for further replies.
Top