Computing.Net > Forums > Programming > Batch Script for setting up

Batch Script for setting up

Reply to Message Icon

Original Message
Name: ryanericw
Date: April 1, 2005 at 00:41:15 Pacific
Subject: Batch Script for setting up
OS: WINXP Pro
CPU/Ram: Ahtlon 2800 XP - 512x2 DD
Comment:

Bah, I'm sorry I really goof'd up. I accidentally thought I copid my whole post from trying to post in another forum, but realized it was in the wrong place.

What I want to know is, how to make a variable in a setup path.

I want the batch to ask for a username with echo, then once you enter the username, it uses the text entered for the variable I set it to.

Can someone please help me, and tell me how to do this?

Thank you very very much. I appreciate any feedback.


Report Offensive Message For Removal

Response Number 1
Name: ryanericw
Date: April 1, 2005 at 00:44:34 Pacific
Subject: Batch Script for setting up
Reply: (edit)

To explain it more.

The batch says for example:


Please enter your Steam Username: (I enter mine) Mysticssjgoku4

I set my path like:

Copy "files\file.wad" "C:\Program Files\Valve\Steam\Steamapps\%Username%\half-life\valve"

I want %Username% as the variable
And I want it to be set to whatever is entered as the username, as below.

Thank you in advance.


Report Offensive Follow Up For Removal

Response Number 2
Name: Mechanix2Go
Date: April 1, 2005 at 01:10:52 Pacific
Subject: Batch Script for setting up
Reply: (edit)

@echo off
echo enter name
set /p Username=


M2

If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 3
Name: ryanericw
Date: April 1, 2005 at 09:46:32 Pacific
Subject: Batch Script for setting up
Reply: (edit)

Thanks man, it works perfectly.
Here's my code.

@echo off
echo Enter Steam Username:
set /p Username=

@ECHO OFF
Echo Copying Files..........
echo off
Echo.

Echo Copying File(s): halflife_3x.fgd (Half-Life Game Data File)
COPY "files\halflife_3x.fgd" "C:\Games\Steam\SteamApps\%username%\half-life\valve"
echo off
pause
Echo.


Report Offensive Follow Up For Removal

Response Number 4
Name: ryanericw
Date: April 1, 2005 at 09:50:10 Pacific
Subject: Batch Script for setting up
Reply: (edit)

Another question. How can I make it so that it repeats the question if the user enters his name wrong and it cannot find the path?

Like he typed "stati" instead of "static". It was on accident, but instead of the batch file continuing, I want it to re-ask the question with a reponse like "Invalid Username, Please Re-enter."

Thnx


Report Offensive Follow Up For Removal

Response Number 5
Name: Mechanix2Go
Date: April 1, 2005 at 10:03:49 Pacific
Subject: Batch Script for setting up
Reply: (edit)

if not exist "C:\Games\Steam\SteamApps\%username%\half-life\valve" echo re-enter name & goto :label


[that's all one line]

and put :label immediately above your set /p line.


M2

If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal


Response Number 6
Name: ryanericw
Date: April 1, 2005 at 10:12:43 Pacific
Subject: Batch Script for setting up
Reply: (edit)

Thank you. So far so good. Everything works perfectly.
Now one big question.

Is it possible to make the batch file read a specified entry in the registry and pull the value from it and insert it into a set variable?

Thanks


Report Offensive Follow Up For Removal

Response Number 7
Name: Mechanix2Go
Date: April 1, 2005 at 10:24:02 Pacific
Subject: Batch Script for setting up
Reply: (edit)

I never mess with the registry.

Maybe somebody else knows.

Do you want to get the users' names and script your setup?

One name at a time or all at once?



M2

If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 8
Name: ryanericw
Date: April 1, 2005 at 10:27:41 Pacific
Subject: Batch Script for setting up
Reply: (edit)

well, I want it to automatically read the first username registered in the registry.
Pull that username from the registry, then set it as the variable.

That way, if I want, I could make the setup fully unattended.


Report Offensive Follow Up For Removal

Response Number 9
Name: Mechanix2Go
Date: April 1, 2005 at 10:45:02 Pacific
Subject: Batch Script for setting up
Reply: (edit)

I don't know much about the reg so I don't know what 'first user' is nor where to find it.

You can use:

NET USER

to get all users



M2

If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 10
Name: ryanericw
Date: April 1, 2005 at 10:54:22 Pacific
Subject: Batch Script for setting up
Reply: (edit)

It's ok. Just, can you direct me to the correct forum to ask this question?

See the registry is just like, information stored. It keeps registry entries. Each entry is like a text file with a line of information in it. Except that text file is opened and the info inside is is used periodically when you open a program.

By user, I meant that for this map editing program, there can be multiple users that use the program. The multiple users are the ones who logged on and played. The username are stored in the registry. I want the batch to pull the first registered username from the registry and insert it into my set variable.


Report Offensive Follow Up For Removal

Response Number 11
Name: Mechanix2Go
Date: April 1, 2005 at 11:23:42 Pacific
Subject: Batch Script for setting up
Reply: (edit)

If you want the current user's name, it's already in a variable called USERNAME.


M2

If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 12
Name: ryanericw
Date: April 1, 2005 at 11:43:06 Pacific
Subject: Batch Script for setting up
Reply: (edit)

Hmm. Ok. I know that. Not what I was wanting to know but. Another little problem here.

They enter their username, and I want them to select the install directory they used from a list I provide.

@echo off
Title Please Enter Steam Username...
echo Enter Steam Username:
set /p Usern=

:usr
cls
Echo Invalid Username.. Please Re-enter
Echo.
@echo off
Title Invalid Username..Please Re-enter Steam Username...
echo Steam Username:
set /p Usern=

if not exist "C:\Games\Steam\SteamApps\%username%\half-life\valve" echo re-enter name & goto :usr

@echo off
:start
cls
Echo Map Installer 1.2
Echo Made by Mysticssjgoku4-Ryan Wehrle-ExtremeKiller
Echo.
Echo.
Echo Choose from the list below the correct path for your Steam Installation.
Echo.
Echo.1 - C:\Games\Steam\Steamapps\%usern%\Half-Life\Valve
Echo.2 - C:\Program Files\Valve\Steam\Steamapps\%usern%\Half-Life\Valve
Echo.3 - Custom Path...
Echo.
set /p userinp=Choice:

set userinp=%userinp:~0,1%
if "%userinp%"=="1" goto Games
if "%userinp%"=="2" goto PF
if "%userinp%"=="3" goto Cst
echo invalid choice
goto start


-------------------------

if not exist "C:\Games\Steam\SteamApps\%username%\half-life\valve" echo re-enter name & goto :usr

I want that path to be a variable as well. I'm having sort of a mental block right now.

From the list, once they select which path. I want it to check that path once they enter the username.


Report Offensive Follow Up For Removal

Response Number 13
Name: Mechanix2Go
Date: April 2, 2005 at 04:08:01 Pacific
Subject: Batch Script for setting up
Reply: (edit)

I've having a block too.

We're going back and forth between 'user input' and 'hands off'.

It's one or the other, like XOR.


M2

If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal






Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Batch Script for setting up

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software