Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

Username in Batch File?

- - - - -

  • Please log in to reply
8 replies to this topic

#1
SilverBulletUK

SilverBulletUK

    Quite likes the Command Line, but not with chips you understand.

  • Member
  • Pip
  • 59 posts
Hey guys,

Need your guidance yet again :wacko: ...!!

Im trying to make a batch file to make a folder named after the user who is logged onto the computer at the time.....

Little explanation......

@echo off
SYSINFO.BAT >> C:\Logs\***username here***\Output.txt
Exit

how could i set the variable needed to replace "***username here***" is this even possible, forgive me this is really simple but its late!!! :}

Does this make any sense?


How to remove advertisement from MSFN

#2
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,527 posts
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

What about using the SET command with the existing Environment Variable %USERNAME%

#3
SilverBulletUK

SilverBulletUK

    Quite likes the Command Line, but not with chips you understand.

  • Member
  • Pip
  • 59 posts
Yeah, i was thinking somehting along thos lines but wasn't entirely sure as to how to use it...Ie syntax etc....

#4
SilverBulletUK

SilverBulletUK

    Quite likes the Command Line, but not with chips you understand.

  • Member
  • Pip
  • 59 posts
Ah ha!

Cheers Fella!! :D

%USERNAME% Worked........Now ive just got to figure out how to make the following Directory Structure...

%username%\%DATE%\%TIME%\

And yes....ive tried the above Vars :P Ideas...?

#5
SilverBulletUK

SilverBulletUK

    Quite likes the Command Line, but not with chips you understand.

  • Member
  • Pip
  • 59 posts
::BUMP::

Anyone know how to make the Date & Time folders as stated above please???

:D

#6
SiMoNsAyS

SiMoNsAyS

    C'mon you apes! You wanna live forever!?

  • Patrons
  • 3,455 posts
mmm problem is that the simbols used for date and time ("\", "/", ":") can not be used to create the folder...

maybe sending the strings to a .txt file... dunno :unsure:

#7
SilverBulletUK

SilverBulletUK

    Quite likes the Command Line, but not with chips you understand.

  • Member
  • Pip
  • 59 posts
Ahhhh,

Explains why when I try i get %username%\Logs\25\01\05\

Intresting theory you get there.....but how to get rid of the "\" in the output.....

Guess im off to google for a few more hours...! :D

#8
DotBet

DotBet

    Newbie

  • Member
  • 13 posts
Check your other thread.

I posted a reply that may help.

http://www.msfn.org/...pic=37572&st=0

#9
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,418 posts
  • OS:none specified
  • Country: Country Flag
This Makes A Folder Based On The Current Date

@echo off
cls 
color F2
mode con: Cols=55 Lines=3
Title What Year Is It Test 2
SET D1=%date:~-4,10%
SET D2=%date:~7,-5%
SET D3=%date:~4,-8%
SET D4=%date:~0,-10%
echo.
@echo The Year Is %D1%
ping -n 3 127.0.0.1>nul
cls
echo.
@echo Today Date %D2%
ping -n 3 127.0.0.1>nul
cls
echo.
@echo The Month %D3%
ping -n 3 127.0.0.1>nul
cls
echo.
@echo The Day %D4%
ping -n 3 127.0.0.1>nul

if exist %D3%-%D2%-%D1% goto E1 
if not exist %D3%-%D2%-%D1% goto W1

:W1
mkdir %D3%-%D2%-%D1%
echo.
echo Folder %D3%-%D2%-%D1% Was Made!
ping -n 3 127.0.0.1>nul
exit

:e1
echo.
echo Folder Was Already Made!
ping -n 3 127.0.0.1>nul
The Folder Named Would Be 02-07-2005 or The Day
It Was ran On
Adjust To your Needs

Edited by gunsmokingman, 19 October 2007 - 11:39 AM.



GunSmokingMan






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN