Hi,

Here's my problem:

I want to shedule on legacy Windows Servers (Windows 2000 Servers) to run
the Sysinternals contig.exe application, which is very useful and powerful to
defragment drives and folders.

But before running the contig.exe, you have to accept the EULA by clicking
on the "I accept" button of a pop-up window. Once accepted, several keys and
a dword are added to the registry.

I want to schedule this task by using a "special user" allowed to connect as
a batch job only. It doesn't have any profile, and, very important, doesn't
have any keys in the registry under the HKEY_USERS.
Once running this script for the first time by the scheduler, the EULA
pop-up is not displayed, so no new keys can be added to the registry, and
then the script cannot run and waits for the click on the "I accept the EULA"
button.

My goal is to create automatically the keys and the dword value before the
schedule task runs this script, and then the EULA will be already accepted
without clicking on this button.

Can someone explain me why in the following script, the creation of the keys
and the value is not working. Thanks a lot.

The steps are:
1 - getting the SID of my special user
2 - creating the key with the SID under HKEY_Users
3 - creating all the key and subkeys for the Sysinternals contig application
4 - creating the new dword named "EulaAccepted" with a value of '1'


----------------------------------------------------

' Get the Account SID of the user used by the scheduler
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objAccount =
objWMIService.Get("Win32_UserAccount.Name='user',Domain='domain'")
accountSID = objAccount.SID

' Add the reg entry so it accepts the Sysinternals EULA
Const HKEY_USERS = &H80000003

Set StdOut = WScript.StdOut

Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
strComputer & "\root\default:StdRegProv")

strKeyPath = accountSID
Wscript.Echo "Creating the key with the SID: " & strKeyPath
objReg.CreateKey HKEY_USERS,strKeyPath

strKeyPath = strKeyPath & "\Software"
Wscript.Echo "Creating the key with Software: " & strKeyPath
objReg.CreateKey HKEY_USERS,strKeyPath

strKeyPath = strKeyPath & "\Sysinternals"
Wscript.Echo "Creating the key with Sysinternals: " & strKeyPath
objReg.CreateKey HKEY_USERS,strKeyPath

strKeyPath = strKeyPath & "\C"
Wscript.Echo "Creating the key with C: " & strKeyPath
objReg.CreateKey HKEY_USERS,strKeyPath

strEntryName = "EulaAccepted"

dwValue = 1
Wscript.Echo "Setting the value of " & strEntryName & " to " & dwValue
objReg.SetDWORDValue HKEY_USERS,strKeyPath,strEntryName,dwValue

objReg.GetDWORDValue HKEY_USERS,strKeyPath,strEntryName,dwValue
Wscript.Echo strEntryName & " = " & dwValue

------------------------------------------------------

And here's the output:

==============================

accountSID = S-1-5-21-2304659736-2020637620-97400744-1039
Creating the key with the SID: S-1-5-21-2304659736-2020637620-97400744-1039
Creating the key with Software:
S-1-5-21-2304659736-2020637620-97400744-1039/Software
Creating the key with Sysinternals:
S-1-5-21-2304659736-2020637620-97400744-1039\Software\Sysinternals
Creating the key with C:
S-1-5-21-2304659736-2020637620-97400744-1039\Software\Sysinternals\C
Setting the value of EulaAccepted to 1
EulaAccepted =

===================================

Nothing is created in the registry.

I am a local administrator of my server (not attached to any domain).

Thanks again for your help.
Yann

Re: Modifying the Registry by Ayush

Ayush
Fri Jan 26 21:35:13 CST 2007

Replied to [Yann]s message :

> I want to schedule this task by using a "special user" allowed to connect as
> a batch job only. It doesn't have any profile, and, very important, doesn't
> have any keys in the registry under the HKEY_USERS.
> Once running this script for the first time by the scheduler, the EULA
> pop-up is not displayed, so no new keys can be added to the registry, and
> then the script cannot run and waits for the click on the "I accept the EULA"
> button.


Why not use SendKeys to press the I Agree button ?

--
â?? Ayush
-------------
Search - www.Google.com | Wikipedia - http://en.wikipedia.org
Snip your long urls - http://snipurl.com/
-------------

Re: Modifying the Registry by Yann

Yann
Sat Jan 27 21:17:00 CST 2007

Ayush, can it work even if no session is open? because I read it was not
possible to interact with the desktop or windows if no session is opened.
I even found a script to deframent Windows 2000 Server only based on some
sendkeys but which can only work if a session is open.

Thanks for your help
Yann

"Ayush" <"ayushmaan.j[aatt]gmail.com" wrote:

>
> Why not use SendKeys to press the I Agree button ?
>
> --
> â?? Ayush