Jump to content

A Run Command Before Windows Logs On


mintel

Recommended Posts

Ive got a question. Is it possible to run a command (a *.cmd file) befor windows logs on (before the log on screen)?

I want to do this, because i want to run a copy command of the document and settings directory, but that is not possible if a user is logged on :no:

Does anybody know how i can do this? Or has an alternative?

Thanx in advance! :thumbup

Link to comment
Share on other sites


Hmm...i think the following would do the trick:

Log on to the computer.

Go to START/RUN and type "cmd" (without "")

Go to your root dir (on which windows resides) (C: for example)

Type CD\ (so you'll be on the very root of the HD)

Type 'edit autoexec.bat' (loading edit can take a couple of seconds...). If autoexec.bat has lines in it, be carefull that you not edit stuff (which does belong in autoexec.bat)

Put the following line somewhere in your file:

xcopy c:\DOCUME~1\*.* /D /E /H x:\destination

x:\destination is your complete path to the dir where the backup has to be placed. You have to work in 8.3 Dos format. This means that when a foldername is longer dan 8 chars, then you'll have to write down the first 6 chars + ~1 (if there are more folders with the same 6 chars, then you'll have to number ~x on alphabet). If the folder name is exactly 8 chars, then you don't have to change destination folder ;) (spaces are not allowed @ dos).

I hope you'll understand what i've said and well, if u need help, i'll try to help :)

Link to comment
Share on other sites

Thanx!

The problem is. It's Windows 2000. They replaced CONFIG.SYS and AUTOEXEC.BAT with CONFIG.NT and AUTOEXEC.NT.

So I tryed to place the following line in the AUTOEXEC.NT:

xcopy %SYSTEMROOT%\TempDocs\*.* %SYSTEMDRIVE%\Docume~1\*.* /S /E /I /Q /H /Y

It didn't run my command nor a give me an error. :no:

Any other suggestions ?

Or should i try to place the above code in AUTOEXEC.BAT and place an line in AUOTEXEC.NT to run AUTOEXEC.BAT ?

THANX IN ADVANCE!

Link to comment
Share on other sites

im not really familar with win2k..

but u need quotes around your statement.. so windows picks up spaces (if there are any) in your files

xcopy "%SYSTEMROOT%\TempDocs\*.*" "%USERPROFILE%\" /S /E /I /Q /H /Y

Link to comment
Share on other sites

Im running win2k here too and well, i don't have a autoexec.nt or what so ever, but i do have autoexec.bat, config.sys and so on. It are hidden files, thats also why i forwarded you to autoexec.bat via CMD.

By the way, your xcopy command switches are a bit strange...

/H == copy hidden

/E == copys folder, even when they're empty

/S == Copy folders when they're not empty (/E and /S are working against eachother)

/I == Target is a folder when target does not exist, remove this one too...

/Q == Dont show copied files..okay.

/Y == Overwrite files without prompting..okay.

I would prefer this:

xcopy %SYSTEMROOT%\TempDocs\*.* %SYSTEMDRIVE%\Docume~1\ /E /I /Q /H /Y

I also removed the *.* at the end of docume~1 cause if you do that, you DO have to 'tell' the comp what the destination is (file or folder)

I think that %SYSTEMROOT% and %SYSTEMDRIVE% doesnt work, cause that is loaded via config.sys and .PATH commands of autoexec.bat

good luck ;-)

Link to comment
Share on other sites

Ok, this is what i'm going to try.

I'm making an Unattended Windows 2000 install cd.

Ive got everyting set, except for the Documents and Settings directory.

The problem is that the Documents and settings dir is nog copied during the setup.

(XP copies the $docs dir and W2K not)

I'm trying to resolve this problem by copying the Docs dir BEFORE windows loads, or just before a user logs in (Administrator of some one else)

You can read in the reply's above that i tried to copy the Docs dir via AUTOEXEC.NT, but doesn't work (AUTOEXEC.NT only defines thet MS-DOS environment, does not run programs from what i read in other sites)

I also tried to use the AutoExNT tool from the ResourceKit

(It runs a service on the computer and then from there it will run a batch file with commands, the trick is this runs before any user logs on. But my experience is that it runs AFTER a user logs on (and then the Docs dir is locked :( ) :angry:

Thanx microsoft! NOT! (How to Run a Batch File Before Logging on to Your Computer

And now i'm stuck. This is the only thing that's not done, after this, the CD is finished.

Any help is welcome, and Thanx in Advance! :thumbup

Link to comment
Share on other sites

Is it possible to run a command (a *.cmd file) befor windows logs on (before the log on screen)?

Does anybody know how i can do this? Or has an alternative?

1. Easy - Copy files over to "%systemdrive%\Docs&Settings\Default User" folder itself, thru cmdlines.txt (T-12) and whatever new users are created will inherit those files.

2. This one is a bit less easy - There is a registry key that can run something just before login. Find this in the registry tweaks thread (in "unattended windows" section of this forum). And then set it and remove on next boot and manipulate it as you please.

Link to comment
Share on other sites

Is it possible to run a command (a *.cmd file) befor windows logs on (before the log on screen)?

Does anybody know how i can do this? Or has an alternative?

1. Easy - Copy files over to "%systemdrive%\Docs&Settings\Default User" folder itself, thru cmdlines.txt (T-12) and whatever new users are created will inherit those files.

2. This one is a bit less easy - There is a registry key that can run something just before login. Find this in the registry tweaks thread (in "unattended windows" section of this forum). And then set it and remove on next boot and manipulate it as you please.

1. Em, I already tried to run that command from the cmdlines (T-12) file, but that didn't work. Both the Xcopy nor the copy command didn't work. I also dit not use variables (maybe they were not defined in this stage of the setup, so just to be sure i used the full path names)

Or should i place those commands in an batch or an command file, ant then run that file from the cmdlines (T-12) file ? :}

2. I searched the 'Unattended Windows' section for that registry entry, without succes (that's why i'm wrighting this reply :) )

I also searched the topic 'Reg tweaks' and 'Reg tweaks part 1', but without succes.

I also downloaded both the Regtweaks zip files, and searched in there. but that also wasn't rewarding :no: (

Does anybody know what the regtweak is or where (exactly) i can find it.

Thanx in advance (again!) :thumbup

Link to comment
Share on other sites

Dunno but u can try to see if there is something under the local policies where it would run scripts during comp startup.. dunno if this is limited to corp installations where xp / 2000 interacts with a DC but check it out..

perhaps.. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupfolder]

then again, dont think this is present during initial installation of the Win32 os.

keep truckin..

Link to comment
Share on other sites

Dunno but u can try to see if there is something under the local policies where it would run scripts during comp startup.. dunno if this is limited to corp installations where xp / 2000 interacts with a DC but check it out..

perhaps.. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupfolder]

then again, dont think this is present during initial installation of the Win32 os.

keep truckin..

Nope i checked in win2k registry for that key, but it doesn't exist. But thanx anyway!

Link to comment
Share on other sites

1. Em, I already tried to run that command from the cmdlines (T-12) file, but that didn't work. Both the Xcopy nor the copy command didn't work. I also dit not use variables (maybe they were not defined in this stage of the setup, so just to be sure i used the full path names)

Well, I always recommend using variables. That will work, or maybe you got a spelling error in your commands previously. :P

Or if commands in a batch-file is not working for you, use RAR SFX to extract silently to a known path. If you need more info about that, just ask. ;)

Link to comment
Share on other sites

1. Em, I already tried to run that command from the cmdlines (T-12) file, but that didn't work. Both the Xcopy nor the copy command didn't work. I also dit not use variables (maybe they were not defined in this stage of the setup, so just to be sure i used the full path names)

Well, I always recommend using variables. That will work, or maybe you got a spelling error in your commands previously. :P

Or if commands in a batch-file is not working for you, use RAR SFX to extract silently to a known path. If you need more info about that, just ask. ;)

Well i tried what you said, but it didn't work :no:

I packed the directory (All users and Default User) in a SFX in DOS modi.

The script whithin in the file is as follows:

Path=c:\docume~1\
SavePath
Silent=1
Overwrite=1

And my cmdlines.txt is as follows:

[COMMANDS]
"REG IMPORT HKCU_Reg.reg"
"Docs.exe"

I also placed the "Docs.exe" in the $OEM$ folder (where also the Docs.exe is placed)

What the *** am i doing wrong :wacko:

Thanx again for all your reply's!

Link to comment
Share on other sites

...

I also tried to use the AutoExNT tool from the ResourceKit

(It runs a service on the computer and then from there it will run a batch file with commands, the trick is this runs before any user logs on. But my experience is that it runs AFTER a user logs on (and then the Docs dir is locked  :(  )  :angry:

Thanx microsoft! NOT! (How to Run a Batch File Before Logging on to Your Computer

...

Thanx os2fan2, but i already tried that option, but it doesn't work. It runs after the user logs on, instead of before...

But thanx again for the reply :thumbup

Link to comment
Share on other sites

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...