Jump to content

Recommended Posts

Posted (edited)

I am currently trying to make a batch file to backup my settings, and I have needed this option for awhile, but I've never been able to find out how to do this... I've seen it done with VBS, bu I have no idea how it was done...

I would like to have a popup box ask to select a file.... Then, I would like to have the box take the selected file (EG C:\program files\my program\myexe.exe) and do something like this inside my batch file...

set program=C:\program files\my program\myexe.exe

that way, I could later do this...

copy "%PROGRAM%" "%SYSTEMDRIVE%\backup"

Along with being able to select an individual file, I would also like to be able to select directories...

Thank you in advance...

Edited by Jman1993

Posted

You cannot directly create a popup per say, but you can get the batch file to ask you the question and wait for a reply.

Here's a basic example with no error trapping at all.

@Echo off&Setlocal enableextensions
Set/p "PROGRAM=Select a file: "
Copy "%PROGRAM%" "%SYSTEMDRIVE%\backup"

Posted
I would like to have a popup box ask to select a file....

You can use a third party app.

For a simple "file asking", check wfile :

http://home.mnet-online.de/horst.muc/w32dial.htm#wfile

For a complete pseudo GUI I recommend Wizard's Apprentice:

http://wizapp.sourceforge.net/

You can do fairly complex things with it in batxh, see this example:

http://home.graffiti.net/jaclaz:graffiti.n...ts/VDM/vdm.html

jaclaz

Posted (edited)

@Yzöwl

That is how I currently do it... But, I then found a batch program called "Firefox addon maker" and it would popup a folder selection window! I just had to have that! I studied the batch and the vbs for almost an hour and got nowhere.... So I really got frustrated...

@jaclaz

This program seems like it would work... But here's what keeps happening...

C:\>Wfolder CD "%SYSTEMDRIVE%" "Select your folder"
cd "C:\Program Files"

C:\>

It says it changes the dir to "C:\program files", but for some reason it doesnt...

The same happens when trying to set variables...

ANy ideas?

Edited by Jman1993
Posted

Well, if you do not call temp.bat it would be tough for it to work. :whistle:

Try this:

Wfolder CD %SYSTEMDRIVE% "Change Directory" > temp.bat
call temp.bat

jaclaz

Posted
Well, if you do not call temp.bat it would be tough for it to work. :whistle:

Try this:

Wfolder CD %SYSTEMDRIVE% "Change Directory" > temp.bat
call temp.bat

jaclaz

AWESOME! It works! I can select files, dirs, and there are some other cool apps on that site... Thanks A LOT :thumbup

Posted
AWESOME! It works!

Sure it does ;), did you actually doubt it? :w00t:

Now, let's get rid of the temp file (2K/XP/2003 and possibly Vista, NOT 9x/Me:

@ECHO OFF
FOR /F "tokens=1,* delims= " %%A in ('Wfolder CD %SYSTEMDRIVE% "Change Directory"') do %%A>nul&cd %%B>nul

The board parses long lines strangely, the above is just TWO lines, first one is:

@ECHO OFF

and all the rest is the second one.

jaclaz

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...