MSFN Forum: Using RunOnceEx for logon scripts - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Using RunOnceEx for logon scripts Rate Topic: -----

#1 User is offline   MaelstromX 

  • Group: Members
  • Posts: 4
  • Joined: 12-March 06

Posted 12 March 2006 - 12:18 PM

I have been playing around on my test network and making some improvements (aesthetic and functional).

Normally in my domains logon scripts I have a main script that calls smaller "function" scripts. This way I keep my code organized and easy to edit.

While perusing the Unattended setup page for some silent installer info I saw the section on RunOnceEX and thought to myself why cant I use this to make my logon scripts more user friendly and pretty". Well, it was actually easier than I thought. Here is what I did.

As I said before my logon script is composed of a "main" script and 3 "function" scripts. All are simple because I am redesigning my network at the moment and adding new features. Here is what my GlobalLogon.cmd used to look like.

@echo off
::
::	This is the core logon script for the test.net domain.
::	It launches all other logon scripts.
::

:START
::
::	Start of Script.  Sets Variables.
::

SET logpath=\\test.net\NETLOGON

:CALLS
::
::	Logon sub-scripts are called here.
::

START "Setting default command prompt path to drive root" /I /WAIT %logpath%\Cmd.cmd
START "Mapping network drives" /I /WAIT %logpath%\MapDrives.cmd
START "Adding BGinfo information to your background" /I /WAIT %logpath%\BGinfo.cmd

:PAUSE
::
::	Pause for debugging (disabled by default)
::

::pause

:END
::
::	End of script
::

EXIT


Using some information from http://unattended.ms...xp/view/web/31/ I converted the central 3 calls to REG ADD entries. Normally the computer will wait until it restarts to run registry values added here so I had to find a way to manually launch the RunOnceEX process.

the solution is to add your values to the registry and use this line of code.
rundll32.exe iernonce.dll,RunOnceExProcess


I still wanted the functions to be run in their own .cmd scripts. So I just used the RunOnceEX to launch these command separately like I was doing in my original. This was however, quite ugly, and the whole point of this was to neaten up the look of things. So I found a small window hiding program called Hidec.exe and added it in to each line.

Here is my new improved GlobalLogon.cmd

@echo off
::
::	This is the core logon script for the test.net domain.
::	It launches all other logon scripts.
::

:START
::
::	Start of Script.  Sets Variables.
::

SET logpath=\\test.net\NETLOGON
SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx

:RUNONCE
::
::	Adds items to Runonce to be used for the logon script
::

REG ADD %KEY% /V TITLE /D "Running Logon Scripts" /f

REG ADD %KEY%\005 /VE /D "Setting default command prompt path to drive root" /f
REG ADD %KEY%\005 /V 1 /D "%logpath%\hidec /w %logpath%\Cmd.cmd" /f

REG ADD %KEY%\010 /VE /D "Mapping network drives" /f
REG ADD %KEY%\010 /V 1 /D "%logpath%\hidec /w %logpath%\MapDrives.cmd" /f

REG ADD %KEY%\015 /VE /D "Adding BGinfo information to your background" /f
REG ADD %KEY%\015 /V 1 /D "%logpath%\hidec /w %logpath%\BGinfo.cmd" /f

rundll32.exe iernonce.dll,RunOnceExProcess

:PAUSE
::
::	Pause for debugging (disabled by default)
::

::pause

:END
::
::	End of script
::

EXIT


Works like a charm. Hope this is helpful to some people.

I attached a .jpg for those of you who want to see the results.


#2 User is offline   jftuga 

  • Member
  • PipPip
  • Group: Members
  • Posts: 283
  • Joined: 27-October 05

Posted 13 March 2006 - 10:57 AM

What is the difference between RunOnce and RunOnceEX?

-John

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy