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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stratup script group policy

Status
Not open for further replies.

clair

MIS
Mar 24, 2001
59
US
Hello everybody,
I have a question about running a startup script via GPO. OS is W2K Professional and XP. I'm trying to run a custom written program, which moves computer from one domain to another and requires 2 reboots.
1st, it copies some files to a local harddrive, moves a computer to a workgroup and reboots. Then (using copied files on a harddrive)it moves a computer to another domain, and reboots again.
Our script has 2 flavors:
suggested move, when a user gets a screen with "ok" and "cancel" (so the script will run, if a user clicks "OK"), and a forced move, when the script will run without user's interraction.
When I run this script through a login script (not a GPO), all is working fine. But I need to run it using a GPO (computer configuration).
My problem is, that after the first reboot, the computer is trying to access a startup script again, can't do it (because it doesn't have rights to a script directory anymore, it's in workgroup now) and gives an error message. The program will move a computer to a new domain anyway, I just don't want the users to get the error message.
I could probably use RunOnce option, but I need for the users to get a "suggested" version of the script every day for a week.

Sorry for the long description. Now is my question - what should I do so the computer won't try to run a startup script after the 1st reboot? Should I specify some registry key deletion in the script I'm running?

Thank you very much for your help,

Claire
 
Have you tried taking your startup script and having it check the Environment Variables?

When you to your first reboot, you are switching from one domain to WORKGROUP.

So you should put a line in your script that checks %USERDOMAIN% to see if the old domain is listed. If the old domain is not listed, then you should have the script END.

Hope that helps.

Microsoft Certified Nut.

 
Hello SgtBeavis,
Thank you for your reply, but this won't help me. I'm running this script as a startup script using GPO, there is no useraccount or a userdomain at this point, no user has logged on yet. The script is run under a computer account.
Also, after a reboot nothing is checked in the script before the computer account is trying to access it. I'm trying to figure out what do I have to do (probably delete some registry thing), so this startup script won't be access after the first reboot.
Thank you,

Claire
 
how about creating a creating a registry key?

Something like this:
1. check for reg key
2. If reg key exists, then end
3. if reg key does not exist, then run a reg file that will create a reg key.
4. run the rest of your script.

Basically, you use your script to create a reg key. When it tries to run a second time, it will see the reg already exists and stop running. This can be done with the computer account, so you should be able to do it at startup. The reg key can be whatever you choose. Something like HKLM\System\Microsoft\myscript
"run"=dword:00000001



Microsoft Certified Nut.

 
I'd ask why you are even bothering going this route? If you use ADMT to migrate your users and computers, the profiles will all get migrated, the user accounts will match and SID history will be preserved. ADMT 2.0 is available for free download from microsoft.com.

I hope you find this post helpful.

Regards,

Mark
 
Hello everybody, thank you for your replies. Well, there is a reason we want to use a GPO to run a migration script. We will clean up with ADMT or a FastLane, but at first we want to run it using a GPO. And creating a registry key won't really help me. After computer reboots, it tries to process the GPOs previously processed on this machine (domain ones included). One of them forces a strartup script. The only problem is - the computer is not in that domain anymore, it was moved to a workgroup - its account doesn't have rights to this startup script anymore, and there's an error message on the screen about it. I need to remove the "memory of the startup script" from the registry. The fact that it can't access the script is not a problem, because the second part of the script was copied onto computer's harddrive and will be run from there. But we don't want the users to see the error message.
So I thought there must be the registry key with the name of the startup script. So if my script will remove that key before the first reboot, the users won't get an error.
Any idea where it can be?

Sorry about such a long post. And thank you for your help,

Claire
 
Ok, I think you want the file called SCRIPT.INI in, C:\WINDOWS\system32\GroupPolicy\Machine\Scripts

You should see your startup script listed there. Try deleting or renaming the file. (it doesn't exist if there are no startup scripts)

Mine looked like this:
[Startup]
0CmdLine=C:\Documents and Settings\boyettrv\Desktop\test.bat
0Parameters=

I ran a bootlog regmon and found nothing accessing my bat file.

Microsoft Certified Nut.

 
Thank you very much, I'll try removing this file and see what happens!!!

Claire
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top