Jump to content


  • 0
Malik4u

Windows 7, Run Once Application

Question

Hello,

 

My purpose is to Sysprep a machine in Audit mode, install applications etc...(that is done) and then supposed to create the image of this PC wiht ghost (master image, suppose its also done).

I need your help how to work with the documents and applications that are supposed to run only once and the first time when user starts the machine

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hello,

 

My purpose is to Sysprep a machine in Audit mode, install applications etc...(that is done) and then supposed to create the image of this PC wiht ghost (master image, suppose its also done).

I need your help how to work with the documents and applications that are supposed to run only once and the first time when user starts the machine

 

Any answer please ?

Only idea i have is RunOnceKey in registry but i would liek to have some professional recommendations to do it and under the light of the SysPrep.

Share this post


Link to post
Share on other sites

  • 0

what do you need to run once ? have you looked at any of the built in commands via unattend.xml

 

check this post on msfn.org

 

http://www.msfn.org/board/topic/139150-working-unattendxml-and-applications-installs/

 

and I quote:

 

 

First logon commands run in the context of the user (most likely an adminstrator but not guaranteed), and SetupComplete.cmd always runs elevated.

 

SetupComplete.cmd runs immediately prior to first logon, First logon commands do not occur until after the first logon. SetupComplete finishes about 5-10 seconds before First Logon commands start. SetupComplete.cmd can make changes to the default user profile, and when done these changes will reflect in the new user profile created at first login, this cannot be done via First Login commands, as the new user profile would already be created before they run.

 

But the most important reason I prefer setupcomplete.cmd, is it takes normal batch commands vs First Logon using batch commands inside an XML block. Much easier to add, delete, and re-order commands using setupcomplete.cmd

 

 

also checkout this from Technet > about SetupComplete.cmd > http://technet.microsoft.com/en-us/library/cc766314%28WS.10%29.aspx

 

Add a Custom Script to Windows Setup

 

You can add custom scripts to Windows Setup that can be configured to run in different circumstances. You can run a custom script:

 

* Immediately after Windows Setup completes.

* If Windows Setup encounters a fatal error.

 

Run a Custom Script after Windows Setup Completes

 

You can make further customizations after Windows Setup completes by adding commands to the %WINDIR%\Setup\Scripts\SetupComplete.cmd file. This file enables you to install additional applications, run custom Windows scripts (cscript/wscript), or make other modifications to the system before a user logs on.

 

Note

Commands in the Setupcomplete.cmd file are executed with local system privilege.

 

After Windows is installed, but before the logon screen appears, Windows Setup searches for the SetupComplete.cmd file in the %WINDIR%\Setup\Scripts\ directory.

 

If a SetupComplete.cmd file is found, the file is executed. Otherwise, installation continues normally. Windows Setup logs the action in the Setupact.log file.

 

Note

You cannot reboot the system and resume running SetupComplete.cmd.

 

Setup does not verify any exit codes or error levels in the script after executing SetupComplete.cmd.

 

The functionality of Setupcomplete.cmd differs from the RunSynchronous and RunAsynchronous commands in that Setupcomplete.cmd runs after Windows Setup completes while the RunSynchronous and RunAsynchronous commands run during Windows Setup.

 

Run a Custom Script if Windows Setup Encounters a Fatal Error

 

If Windows Setup encounters a fatal error, you can configure Setup to automatically launch a script that contains custom commands or actions. A fatal error is an error in which Windows Setup is prevented from completing the installation.

 

This functionality is useful when you automate the installation of many systems at the same time. By enabling this functionality, you can immediately detect when an error occurs during Windows Setup and run custom actions.

 

If Setup encounters a fatal error and is prevented from completing the installation, Setup searches for a command script in the following directory: %WINDIR%\Setup\Scripts\ErrorHandler.cmd. One of two actions will occur, depending on whether the script is found.

 

* If the script is not found, a dialog box is displayed with the error text. A user must dismiss the dialog box before Setup exits.

* If the script is found, the script executes synchronously. No dialog box or error text is displayed. After the ErrorHandler.cmd script completes, Windows Setup exits.

 

Depending on the phase of Windows Setup, the computer will return to the environment from which Setup was executed (for example, a downlevel operating system or Windows PE).

 

There are several ways that you can add the ErrorHandler.cmd file by using the $OEM$ directory structure.

 

* Create a Sources\$OEM$\$$\Setup\Scripts folder in the Windows distribution. Copy the ErrorHandler.cmd file to this directory.

For more information about using $OEM$ files, see Add Content to $OEM$ Folders.

* Create a temporary folder that contains a $$\Setup\Scripts folder structure. Copy the ErrorHandler.cmd file to this directory, and then run Windows Setup with the /m:temp_folder parameter. For example, if you create C:\Temp\SetupFiles\$$\Setup\Scripts\ErrorHandler.cmd, use the following command:

 

setup.exe /m:C:\temp\SetupFiles

 

For more information about the setup.exe /m parameter, see Windows Setup Command-Line Options.

 

There may be instances when Windows Setup encounters more than one error and runs the ErrorHandler.cmd script more than once. When developing the code for ErrorHandler.cmd, ensure that you can run this script multiple times.

 

 

 

Sample SetupComplete.cmd file

 

here's a sample Setupcomplete.cmd file from srvops

 

SetupComplete.cmd

 

@echo off
cd\
start /wait regedit.exe /s c:\windows\setup\win7regsettings.reg
exit

 

win7regsettings.reg

 

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"ConsentPromptBehaviorAdmin"=dword:00000000

[HKEY_CLASSES_ROOT\Folder\shell\Cmd Here]
@="Command &Prompt"

[HKEY_CLASSES_ROOT\Folder\shell\Cmd Here\command]
@="cmd.exe /k pushd %L"

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management]
"DisablePagingExecutive"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL]
"SkipRearm"=dword:00000001

;1st setting - Turn off UAC Prompt for Admin Elevation
;Next 2 settings - Create a Command Prompt entry on the right click menu
;4th setting - is to put the Windows Kernel in memory. Only do this if you have more than 512MB of RAM
;5th setting - setting this to 1 allows for 8 "rearmings of activation" in Vista Business and Ultimate editions.
;A setting of zero allows for only 3 rearms.

 

 

 

cheers

niall

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.