• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 376
  • Last Modified:

logon script targeted to a network share

Experts,
I need to run a script to change license keys on some of my xp workstations. I all ready have the script and it works fine when I run it locally, but I would like to deploy the script using a GPO, or logon script, but I can't figure out how to make it work.

So far I have tried the logon script, but it's not working because I don't know how to target the network share where the script currently resides.

Any help would be greatly appreciated.
0
fyrfyter
Asked:
fyrfyter
  • 11
  • 10
1 Solution
 
mdiglioCommented:
Hello,
Why does this script have to be called?
Can you just run the script that changes the license key.

If your ou consists of computers that need it and computers that don't
we can modify the script to only include certain computers.
Or we can place the computers that need it in a sub OU and attach the startup script to that.

I would do this type of management as a computer startup script if at all possible

If this didn't help, post the script and we'll find a way
0
 
fyrfyterAuthor Commented:
Hi mdiglio,
I guess it doesn’t have to be called, I was just trying some different things to see if I could get it to work (my scripting skills are very meager). We can just run the script.

We can definitely put those computers into a sub-OU. I tried creating a GPO to run as a logon script, and linking it to an OU with a user account in it to test it, but could not seem to get it to run. I am sure I am doing something wrong, I just don’t know what.

Thanks,
0
 
mdiglioCommented:
If the users are not administrators then I think it will fail.
I would recommend linking the GPO to an OU with computers in it,
then putting the script in the  computer config part...not the User Part

computer configuration > windows settings > scripts(startup/shutdown) > startup.

This way you can link it to the computers since it is more of a computer setting anyway.
Also the script will run as SYSTEM which will have the necessary rights to make the changes
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
fyrfyterAuthor Commented:
I will test that out today and get back to you.
0
 
fyrfyterAuthor Commented:
Ok, the script tries to run, but fail with this error from the event log:

Event Type:      Error
Event Source:      UserInit
Event Category:      None
Event ID:      1000
Date:            5/19/2006
Time:            11:19:44 AM
User:            N/A
Computer:      TECHPC-SD
Description:
Could not execute the following script C:\WINDOWS\SYSVOL\domain\scripts\ChangeVLKeySP1.vbs. The system cannot find the file specified.
.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

*****************

Is the computer looking for this file on it's own c drive?
0
 
mdiglioCommented:
Hello,
That does not look like the location of the file if it were set in a computer startup script using a gpo.

did you see this error after you logged in or when the computer was at the ctrl-alt-del screen?

0
 
fyrfyterAuthor Commented:
I set it up as a computer shutdown scritpt. I placed it there (on the dc) because I read in another PAQ that that was a good place to put it. This is kind of where my problem is. I'm not sure how to configure the gpo so that the script will run on a remote pc?

The error was logged in the event log after a reboot.
0
 
mdiglioCommented:
What do you use to manage your gpos?
How much experience with Group Policy Objects do you have...I'm not sure how much detail to give you

I would recommend using gpmc found here:
http://www.microsoft.com/downloads/details.aspx?FamilyID=0a6d4c24-8cbd-4b35-9272-dd3cbfc81887&DisplayLang=en
download and install it on your xp machine.

I would then remove any scripts you put elsewhere that are related to this task.

Then create a new group policy object and link it to an OU with the computers in it
Then add the script here:
computer configuration > windows settings > scripts(startup/shutdown) > startup

If you manage Group Policy the same way from Windows 2000 then this article will walk you through it a little bit
http://www.windowsitpro.com/Article/ArticleID/27330/27330.html
0
 
SilentezCommented:
@fyrfyter, all scripts for executing from GPO must be in \\domain\SYSVOL\domain\scripts\
Just use simple name of script in GPO, like "ChangeVLKeySP1.vbs" without any paths and it'll work.
0
 
fyrfyterAuthor Commented:
Silentez,
Can you elaborate? When configuring the script in the GPO, I simply browsed to the location of the script, which is in "windows\sysvol\domain\scripts". I didn't actually specify the path.
I tried deleting the path and just leaving the file name of the script in the GPO configuration, but it didn't run with the same result "Could not execute the following script C:\WINDOWS\SYSVOL\domain\scripts\ChangeVLKeySP1.vbs. The system cannot find the file specified".

Mdigllio,
I am using the gpmc on a win2k3 domain controller.
I do not have much experience with group policy.
I followed your instructions in the last post, and am having the same result. I'm not sure what I am missing? The policy is enforced, the link is enabled, is there some security setting that must be made in the security filtering window?

One thing that I find curious is when I am in the Group Policy editor>Startup properties dialog box, I can see the path to the script in the window, but when I click on "show files" there is nothing listed there? Shouldn't my script be listed there?

0
 
mdiglioCommented:
Hello,

I can see where this is getting a bit confusing
These are 2 sepearte methods for managing your scripts.
One way is the method you said you saw in previous PAQs which is the same as Silentez comment.
The other is using Group Policy. Group Policy just places the scripts in the appropriate place for you.
Be it a Computer startup, computer shutdown, user logon or user logoff

I happen to prefer running them all through Group Policy.

"One thing that I find curious is when I am in the Group Policy editor>Startup properties dialog box, I can see the path to the script in the window, but when I click on "show files" there is nothing listed there? Shouldn't my script be listed there?"

Good you are close! This path that you see in the GPEditor is not the same path as where you placed the .vbs file earlier.
You will need to copy and paste your ChangeVLKeySP1.vbs file into there

Before you click 'Show Files' again Open windows explorer > tools > folder options > click the 'view' tab > Now check 'display full path in address bar'
That location you first placed the files was .....WINDOWS\SYSVOL\domain\scripts\
After you make that change in Windows Explorer you will see the path that Group Policy uses is completely different.
It will look like this
....\Yourdomain\Policies\{SOMEGUID-02CE-47C0-8A19-L23EDDD2ED80}\Machine\Scripts\Startup





0
 
fyrfyterAuthor Commented:
Hi Mdiglio,
Are you saying that I must manually copy the the script to "....\Yourdomain\Policies\{SOMEGUID-02CE-47C0-8A19-L23EDDD2ED80}\Machine\Scripts\Startup"?
0
 
mdiglioCommented:
Yes That is right. So after you click 'Show Files' you will copy and paste the .vbs file into that window

Sorry, for not being too clear on the matter
0
 
fyrfyterAuthor Commented:
No problem! I'm sure this seems very clear to you guys, but to me it is a little confusing. Thank you for your patience.

I'll test it out and get back to you.
0
 
fyrfyterAuthor Commented:
Mdiglio,
Now the script has made some progress, but is hanging up with the error "Script can't run without VolumeProductKey argument". This is the same error I received before I put that argument into a batch file and ran it locally that way. This is the reason that I originally called the script from a batch file.

Here is the syntax I used in the bat file to get the vbs script to run:
cmd /c "c:\scripts\ChangeVLKeySP1.vbs xxxxx-xxxxx-xxxxx-xxxxx-xxxxx"
exit

With the ChangeVLKeySP1.vbs in the c:\scripts folder it ran fine.
0
 
fyrfyterAuthor Commented:
One more thing I forgot is that after the "Script can't run without VolumeProductKey argument" error, I get a window that says:
"Correct usage: Cscript ChangeVLKeySP1.vbs xxxxx.xxxxx.xxxxx.xxxxx.xxxxx"
0
 
mdiglioCommented:
OK There are a few ways to go about this.

Change the .vbs file by clicking the 'Show Files' button and then right click ChangeVLKeySP1.vbs >  choose 'Edit'

Then replace the file with this, I have tested it and it works but you should test it as well
You will have to hard code the key into this line
VOL_PROD_KEY = "ENTER YOUR KEY HERE IN QUOTES" :


'Begin New Script

ON ERROR RESUME NEXT


Dim VOL_PROD_KEY
VOL_PROD_KEY = "ENTER YOUR KEY HERE IN QUOTES"
VOL_PROD_KEY = Replace(VOL_PROD_KEY,"-","") 'remove hyphens if any
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WPAEvents\OOBETimer" 'delete OOBETimer registry value
for each Obj in GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf ("win32_WindowsProductActivation")

   result = Obj.SetProductKey (VOL_PROD_KEY)

   if err <> 0 then
      WScript.Echo Err.Description, "0x" & Hex(Err.Number)
      Err.Clear
   end if

Next

'End New Script
0
 
mdiglioCommented:
What this did was eliminate the need for the VolumeProductKey argument because we hard coded it into the script

If you wanted to stick with the original .vbs file let me know and I'll walk you through the second method.
Its a little more involved
0
 
fyrfyterAuthor Commented:
That seemed to work! A couple of questions though:
1. After this script is run on target computers, should I remove those computer accounts from that OU?
2. The scripts didn't run on the first reboot. It needed a second reboot to run. Why is that?
3. What is that scripting language you used (purely out of curiosity)?

Thanks mdiglio,
0
 
mdiglioCommented:
Great, glad it seems to be workng!

1) Yes you can remove those computers from that OU after the script has run

2) That answer would depend upon how long it took from the time you placed the file in there and/or moved the computers
into their new OU until the time the computers were rebooted. If you have multiple sites perhaps there was a replication delay ?
I really can't say

3) we were using Visual Basic Script  .vbs
0
 
fyrfyterAuthor Commented:
3) Duh, I guess the .vbs extension should have given it away <:o

I'll double the points since we deviated from the original topic and found a resolution along other lines.

I really appreciate your help!

Thank you.

And thank you Silentez for your input. Mdiglio took it to town though:)
0
 
mdiglioCommented:
Thanks for the points.
Glad you got it working
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 11
  • 10
Tackle projects and never again get stuck behind a technical roadblock.
Join Now