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

A Run Command Before Windows Logs On

- - - - -

  • Please log in to reply
14 replies to this topic

#1
mintel

mintel
  • Member
  • 9 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


How to remove advertisement from MSFN

#2
Honnes

Honnes

    Newbie

  • Member
  • 23 posts
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 :)

#3
mintel

mintel
  • Member
  • 9 posts
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!

#4
MCT

MCT

    MSFN Junkie

  • Member
  • PipPipPipPipPipPipPipPipPip
  • 3,291 posts
  • OS:none specified
  • Country: Country Flag
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
Posted Image Posted Image
Windows 7 32Bit 2GB Ram 120GB HDD (Laptop), Windows 8 4GB Ram 1TB HDD (Desktop) Windows XP SP3 VM with enhancements!

#5
Honnes

Honnes

    Newbie

  • Member
  • 23 posts
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 ;-)

#6
valter

valter

    Professor

  • Member
  • PipPipPip
  • 427 posts
íf you have another computer, use admin share c$ and copy what ever you want ...

#7
mintel

mintel
  • Member
  • 9 posts
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

#8
prathapml

prathapml

    Follow the rules please :-)

  • Patrons
  • 6,791 posts
  • OS:Windows 8 x64
  • Country: Country Flag

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?

<{POST_SNAPBACK}>

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.
Posted ImageCheers !!!   Donate to MSFN and Help Keep This Site Running
||Please Read the Forum Rules||  Etiquette   || Welcome to MSFN - Forum Basics || Before posting
prathapml :: MSFN Supermod :: Private Message me if you ever have a problem while at MSFN

#9
mintel

mintel
  • Member
  • 9 posts

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?

<{POST_SNAPBACK}>

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.

<{POST_SNAPBACK}>


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

#10
Br4tt3

Br4tt3

    World famous sausage eater...

  • Member
  • PipPipPipPip
  • 566 posts
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..
Sponsored by Swedish Meat!
Tha Sausage Eater...

Please read before posting in forums: http://support.microsoft.com/kb/555375

#11
mintel

mintel
  • Member
  • 9 posts

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

<{POST_SNAPBACK}>


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

#12
prathapml

prathapml

    Follow the rules please :-)

  • Patrons
  • 6,791 posts
  • OS:Windows 8 x64
  • Country: Country Flag

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)

<{POST_SNAPBACK}>

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. ;)
Posted ImageCheers !!!   Donate to MSFN and Help Keep This Site Running
||Please Read the Forum Rules||  Etiquette   || Welcome to MSFN - Forum Basics || Before posting
prathapml :: MSFN Supermod :: Private Message me if you ever have a problem while at MSFN

#13
mintel

mintel
  • Member
  • 9 posts

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)

<{POST_SNAPBACK}>

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

<{POST_SNAPBACK}>


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!

#14
os2fan2

os2fan2

    Advanced Member

  • Member
  • PipPipPip
  • 421 posts
Proggie called 'autoexecnt.exe' is what you're looking for.

zb http://www.jsiinc.com/dl/autoexnt.zip

#15
mintel

mintel
  • Member
  • 9 posts

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

<{POST_SNAPBACK}>


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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN