Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
First, let me give you a background. Here at work, everyone is assigned a user id (i.e. u257949 or u259974). They're always a "u" and 6 digits. That is what their username for windows is set to (i.e. "C:\Documents and Settings\u257949"). What I need to do now is create a batch file to delete a file (named YIPN.BAT) from the user's Startup folder (i.e. "C:\Documents and Settings\u257949\Start Menu\Programs\Startup"). Because not everyone has these files, they were not placed in the All Users directory, thus the need to get the current user.
I've done massive google searches and I cannot get it to work. I've tried to do two different methods; 1) asking the user for input and plugging it in to the "username" space and 2) getting the current user from the registry and plugging it in. I can get both methods two work alone, but cannot integrate it in to my "erasing" batch. I must admit that I am a newbie at creating batches, so this may be something simple. I know a lot of DOS commands, but this just blows me away for some reason.
Oh, also, I would just give each user instructions on how to delete the file, but most everyone here is about 75% computer illeterate and it would take forever just to delete the one file. That is why I am trying to create a batch file to do it for me.
I'm at a stand still so if you can help, please do. Thanks!

create batch "fclean.bat" file with userinput option and put it somewhere on network or in their c:\
del C:\Documents and Settings\%1\Start Menu\Programs\Startup\yipin.bat
If the file is in their c:\, The user goes to start, then run
enter the following:
fclean u123456(return)It should substitute their user number for the %1 in the batch file.
If you have a typical mapped drive, put it there. If it's drive X: then the user would put the following at the run prompt:
X:\fclean u123456

Sound like a job for AutoIt (getAutoItv3Setup.exe).
; You can compile this sample script into an EXE
;
$usr = RegRead("HKEY_...", "Foo...")FileDelete("C:\Documents and Settings\" & $usr & "\Start Menu\Programs\Startup\YIPN.BAT")
MsgBox(0,"FYI", "Operation completed!")

Wow, thanks Randall Lewis. Worked like a charm with a little bit of editing. Instead of being:
"del C:\Documents and Settings\%1\Start Menu\Programs\Startup\yipin.bat"It should be:
"del C:\Docume~1\%1\StartM~1\Programs\Startup\YIPN.bat"But just that simple fix was all I needed. Thanks again! (P.S. CyberSlug, I couldn't figure out how to use AutoIt. Any documentation anywhere?)

Glad you got it to work!
(AutoIt should come with a help file in its directory, or you can download it here.)

![]() |
![]() |
![]() |

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