Computing.Net > Forums > Programming > batch file command?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

batch file command?

Reply to Message Icon

Name: rm3sweet
Date: November 5, 2005 at 09:33:49 Pacific
OS: windows xp home edition
CPU/Ram: amd 1600+
Comment:

What I'm trying to do is create a batch file command that (cd) changes the directory for which it performes a task without knowing the path.

example: "cd c:\documents and settings\%allusers%"
Then automatically change to that directory.
example: cd c:\documents and settings\%user1%
then: cd c:\documents and settings\%user2%
This is to accomplish a task in each unknown path such as "del" or "rd".



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: November 5, 2005 at 09:52:36 Pacific
Reply:

Try this:

:: chgr.bat
@echo off

:main

pushd "C:\Documents and Settings
for /f "tokens=* delims=" %%U in ('dir /ad /b') do call :users %%U
popd
goto :eof

:users

cd "%*"
:: :: your command[s] go here
cd ..
:: DONE



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

M2


0

Response Number 2
Name: Dr. Nick
Date: November 5, 2005 at 23:10:35 Pacific
Reply:

Huh.

Never heard of the pushd/popd commands. Learn something new every day :)

(Though I've started moving away from batch files to WSH. Highly anticipating Monad ;)


0

Response Number 3
Name: Mechanix2Go
Date: November 5, 2005 at 23:23:15 Pacific
Reply:

Monad?


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

M2


0

Response Number 4
Name: Dr. Nick
Date: November 5, 2005 at 23:28:20 Pacific
Reply:

The codename for MSH - Microsoft Scripting Host. It's like bash scripting for Windows, but on steroids. Going to be available for XP, 2003, and Vista. You can actually already download the beta version, info at the Channel9 Wiki.

Some info here and more here.

Using C# to script Windows... drooling already :)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: batch file command?

Batch file commands help ! www.computing.net/answers/programming/batch-file-commands-help-/16201.html

Simple Batch File command help www.computing.net/answers/programming/simple-batch-file-command-help/16568.html

Batch file command line args www.computing.net/answers/programming/batch-file-command-line-args/4226.html