Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sysprep removing registry key required

Status
Not open for further replies.

y2k1981

Programmer
Aug 2, 2002
773
IE
hi all,

I'm using sysprep to take an image of a PC and then deploy to multiple PC's. I have a slight problem however, we need to do a reboot and so have put the appropriate entry in the runonce key - problem is that sysprep removes it !!!!! Is there anyway that we can get around this so that sysprep doesn't remove it?
 
Is the issue forcing a reboot, or forcing a registry change?

. registry changes during unattended install
In particular:
. Force a reboot
I use the "Sendkeys" feature.
You have several moments during the installation in which a script, .bat or .cmd file can be run, so you will have to pick your spot.

There likely is a more elegant solution, but mine works.
 
sorry, I didn't explain very well. escentially I need to force a reboot, but can't do it in the answerfile because of the imaging software that we're using (it's custom built). So I put an entry in the RunOnce key in the registry, but sysprep keeps removing it. Is there any way that I can get sysprep not to remove it?
 
good website, but couldn't find anything there about forcing a shutdown or restart. It's a bit of a catch-22, sysprep removes it but still I can put it in there by putting it in the answerful. seems a bit pointless that sysprep would remove it in the first place at all then!! I'm gonna do a bit more searching, hopefully I'll find it. If I do I'll let you know.
 
create a cmdlines.txt file as discussed in
Point that to a reg file that you have created as per the instructions in
This regfile should have the following in it:

Code:
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx]
"Shutdown"="%systemroot%\\system32\\shutdown -r"

This should get you sorted hopefully

Greg Palmer
Free Software for Adminstrators
 
can somebody explain to me what the RunOnceEx key does? I've been looking on the net but now found much. I did put something in there and then resealed and rebooted (to see if it got deleted during sysprep) and it was still there after the mini installation but didn't run the requierd program.

would somebody mind explaining. thanks to everybody for your help
 
I decided to have another go at putting something in RunOnce (not RunOnceEx) in the registry. i've done it twice now, ie put it in the registry, resealed it etc and it ran the program I wanted during the mini setup. why did it do this? Now I'm confused about whether the entries do get removed from RunOnce or not. This just gets more confusing all the time. Is it possible that it doesn't get removed, but that because the initial entry I put in there was to call shutdown.exe that it didn't work - that there's something in the mini setup to prevent it from being shutdown during setup? If I put shutdown -r -t 600 (60 seconds by 10 mins) would it work because there's enought of a delay?

sorry about all the confusion, I am greatful for all the replies
 
Here's a little background (I'll try to be as brief as possible !!). TrendMicro uses a id similar to a SID for each machine it runs on. It does have a utility however which will remove the SID and will then run on next reboot to generate a new SID. This gets entered in the run key in the registry rather than the run once key. Then is somehow gets deleted along with the file. So after mini setup, the machin autologs on as local admin (this is already in the answerfil and works fine) and then this utility runs. it's at this point that we need to reboot and unfortunately the utility doesn't require a reboot so it won't happen automatically.

thanks again for your help
 
sorry about all the replies, but I've FINALLY figured out what's happening. After the mini setup, it PC reboots, so the entry is going to be removed from RunOnce then. So turns out sysprep doesn't remove it after all. still don't know how we're going to get around this thought !!!!!!
 
How about use the ability to run a batch file to schedule a shutdown?


AtSchedules commands and programs to run on a computer at a specified time and date. You can use at only when the Schedule service is running. Used without parameters, at lists scheduled commands.

Syntax
at [\\ComputerName] [{[ID] [/delete]|/delete [/yes]}]

at [[\\ComputerName] hours:minutes [/interactive] [{/every:date[,...]|/next:date[,...]}] command]

Parameters
\\ComputerName
Specifies a remote computer. If you omit this parameter, at schedules the commands and programs on the local computer.
ID
Specifies the identification number assigned to a scheduled command.
/delete
Cancels a scheduled command. If you omit ID, all of the scheduled commands on the computer are canceled.
/yes
Answers yes to all queries from the system when you delete scheduled events.
hours:minutes
Specifies the time when you want to run the command. Time is expressed as hours:minutes in 24-hour notation (that is, 00:00 [midnight] through 23:59).
/interactive
Allows command to interact with the desktop of the user who is logged on at the time command runs.
/every:
Runs command on every specified day or days of the week or month (for example, every Thursday, or the third day of every month).
date
Specifies the date when you want to run the command. You can specify one or more days of the week (that is, type M,T,W,Th,F,S,Su) or one or more days of the month (that is, type 1 through 31). Separate multiple date entries with commas. If you omit date, at uses the current day of the month.
/next:
Runs command on the next occurrence of the day (for example, next Thursday).
command
Specifies the Windows command, program (that is, .exe or .com file), or batch program (that is, .bat or .cmd file) that you want to run. When the command requires a path as an argument, use the absolute path (that is, the entire path beginning with the drive letter). If the command is on a remote computer, specify Universal Naming Convention (UNC) notation for the server and share name, rather than a remote drive letter.
/?
Displays help at the command prompt.
Remarks
Schtasks is a more powerful superset command-line scheduling tool and includes all the functionality found in the at command-line utility. Use schtasks instead of at for all command-line scheduling tasks. For more information about schtasks, see Related Topics.

Using at
To use at, you must be a member of the local Administrators group.

Loading Cmd.exe
At does not automatically load Cmd.exe, the command interpreter, before running commands. If you are not running an executable (.exe) file, you must explicitly load Cmd.exe at the beginning of the command as follows:

cmd /c dir > c:\test.out

Viewing scheduled commands
When you use at without command-line options, scheduled tasks appear in a table formatted similar to the following:

Status ID Day Time Command Line
OK 1 Each F 4:30 PM net send group leads status due
OK 2 Each M 12:00 AM chkstor > check.file
OK 3 Each F 11:59 PM backup2.bat
Including identification number (ID)
When you include identification number (ID) with at at a command prompt, information for a single entry appears in a format similar to the following:

Task ID: 1

Status: OK

Schedule: Each F

Time of Day: 4:30 PM

Command: net send group leads status due
After you schedule a command with at, especially a command that has command-line options, check that the command syntax is correct by typing at without command-line options. If the information in the Command Line column is incorrect, delete the command and retype it. If it is still incorrect, retype the command with fewer command-line options.

Viewing results
Commands scheduled with at run as background processes. Output is not displayed on the computer screen. To redirect output to a file, use the redirection symbol (>). If you redirect output to a file, you need to use the escape symbol (^) before the redirection symbol, whether you are using at at the command line or in a batch file. For example, to redirect output to Output.text, type:

at 14:45 c:\test.bat ^>c:\output.txt

The current directory for the executing command is the systemroot folder.

Changing system time
If you change the system time at a computer after you schedule a command to run with at, synchronize the at scheduler with the revised system time by typing at without command-line options.

Storing commands
Scheduled commands are stored in the registry. As a result, you do not lose scheduled tasks if you restart the Schedule service.

Connecting to network drives
Do not use a redirected drive for scheduled jobs that access the network. The Schedule service might not be able to access the redirected drive, or the redirected drive might not be present if a different user is logged on at the time the scheduled task runs. Instead, use UNC paths for scheduled jobs. For example:

at 1:00pm my_backup \\server\share

Do not use the following syntax, where x: is a connection made by the user:

at 1:00pm my_backup x:

If you schedule an at command that uses a drive letter to connect to a shared directory, include an at command to disconnect the drive when you are finished using the drive. If the drive is not disconnected, the assigned drive letter is not available at the command prompt.

Examples
To display a list of commands scheduled on the Marketing server, type:

at \\marketing
To learn more about a command with the identification number 3 on the Corp server, type:

at \\corp 3
To schedule a net share command to run on the Corp server at 8:00 A.M. and redirect the listing to the Maintenance server, in the Reports shared directory, and the Corp.txt file, type:

at \\corp 08:00 cmd /c "net share reports=d:\marketing\reports >> \\maintenance\reports\corp.txt"
To back up the hard drive of the Marketing server to a tape drive at midnight every five days, create a batch program called Archive.cmd, which contains the backup commands, and then schedule the batch program to run, type:

at \\marketing 00:00 /every:5,10,15,20,25,30 archive
To cancel all commands scheduled on the current server, clear the at schedule information as follows:

at /delete
To run a command that is not an executable (that is, .exe) file, precede the command with cmd /c to load Cmd.exe as follows:

cmd /c dir > c:\test.out
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top