Dan25 Posted June 27, 2006 Share Posted June 27, 2006 Ok heres the sceneraio, where running Windows Xp SP2 and after imaging a machine with the same image as the other where everything on each machine are identical the hardware wizard likes to load after the image is loaded. Now heres are work around. We go into Windows services and disable the plug and play service on the inital image, this makes it to where when Windows loads it doesnt give that found new hardware wizard. We found if we associate an App we created with a user that when the user logs in the first time it will automatically turn the Plug and play service back on, but heres the catch they then would have to reboot the machine once for the settings to take effect. Like after runnin the fix if a reboot doesnt happen then the usb thumb drives wont work until the reboot. My question is this. Is there a script we can incorporate that will refresh the registry and we dont have to do a reboot? Or rather than making an App in Zenworks that turns the Plug and Play service back on when a user logs in, Is it possible to have a script that will execute at certain times like this, turn the Plug and play service back on after this amount of time has past and then refresh the registry so that a reboot is not needed. An explanation in detail would be great if this is possible being that I have no scripting knowledge really. Link to comment Share on other sites More sharing options...
Briegel Posted June 27, 2006 Share Posted June 27, 2006 I think you only must enable the service and then run the command "net start servicename". Link to comment Share on other sites More sharing options...
Dan25 Posted June 28, 2006 Author Share Posted June 28, 2006 Come on this forum has alot of people with script knowledge, could I please get more detailed input on this, this is something I need to implement by tommorow in our image before I present the final image to our Director. Dont let this post make it to the second page like it just did, please. Keep this one alive. Link to comment Share on other sites More sharing options...
nitekram Posted June 28, 2006 Share Posted June 28, 2006 Come on this forum has alot of people with script knowledge, could I please get more detailed input on this, this is something I need to implement by tommorow in our image before I present the final image to our Director. Dont let this post make it to the second page like it just did, please. Keep this one alive.Have you thought of each chip on the MB - as this would need to be updated to make sure the OS works. I know that I have seen the same model have different chips before. I do not have any other input on this though. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow."  WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI  CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Skruge Posted June 28, 2006 Share Posted June 28, 2006 Welcome to the forums! There are much better ways to do this, but since you're in a hurry, this should work: RunWait("sc config plugplay start= auto") RunWait("sc start plugplay")No need for a timer, since we want the change to take effect instantly. Read the help file and post any changes if you get stuck. Good luck! [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
Dan25 Posted June 28, 2006 Author Share Posted June 28, 2006 Welcome to the forums! There are much better ways to do this, but since you're in a hurry, this should work: RunWait("sc config plugplay start= auto") RunWait("sc start plugplay")No need for a timer, since we want the change to take effect instantly. Read the help file and post any changes if you get stuck. Good luck! So what about having to do a refresh of the registry or a reboot, we noticed that when we reenabled the service, the thumb drives still wouldnt work and a reboot was need, does something need to be added to the script to have it refresh the registry settings? Link to comment Share on other sites More sharing options...
Dan25 Posted June 28, 2006 Author Share Posted June 28, 2006 Bump... Link to comment Share on other sites More sharing options...
Danny35d Posted June 28, 2006 Share Posted June 28, 2006 (edited) Before you try to do the script check if refreshing the registry will make the thum drive work. Right click taskbar and select task manager from the processes tab select explorer.exe and then end process. Keep task manager open Go to File and select New Task(Run...) type explorer.exe and then check if the thumb drive works.if after this test the thumb drive work you can use EnvUpdate( ) function to simulate log off, then log on and refresh the registry. Edited June 28, 2006 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
Dan25 Posted June 30, 2006 Author Share Posted June 30, 2006 ScanForHardwareChanges() Func ScanForHardwareChanges() Local Const $CM_LOCATE_DEVNODE_NORMAL = 0 Local Const $CR_SUCCESS = 0 $status = DLLCall("cfgmgr32.dll","int","CM_Locate_DevNode", _ "int_ptr",0,"int",0,"int",$CM_LOCATE_DEVNODE_NORMAL) If Not ($status[0] = $CR_SUCCESS) Then MsgBox(4096,"","CM_Locate_DevNode failed: " & $status[0]) Return 0 EndIf $status = DLLCall("cfgmgr32.dll","int","CM_Reenumerate_DevNode","int",$status[1],"int",0) If Not ($status[0] = $CR_SUCCESS) Then MsgBox(4096,"","CM_Reenumerate_DevNode failed: " & $status[0]) printf("CM_Reenumerate_DevNode failed: %x\n", status)); Return 0 EndIf Return 1 EndFunc So does that script do the scan without popping up the wizard that says windows has detected new hardware? Link to comment Share on other sites More sharing options...
Dan25 Posted June 30, 2006 Author Share Posted June 30, 2006 ScanForHardwareChanges() Func ScanForHardwareChanges() Local Const $CM_LOCATE_DEVNODE_NORMAL = 0 Local Const $CR_SUCCESS = 0 $status = DLLCall("cfgmgr32.dll","int","CM_Locate_DevNode", _ "int_ptr",0,"int",0,"int",$CM_LOCATE_DEVNODE_NORMAL) If Not ($status[0] = $CR_SUCCESS) Then MsgBox(4096,"","CM_Locate_DevNode failed: " & $status[0]) Return 0 EndIf $status = DLLCall("cfgmgr32.dll","int","CM_Reenumerate_DevNode","int",$status[1],"int",0) If Not ($status[0] = $CR_SUCCESS) Then MsgBox(4096,"","CM_Reenumerate_DevNode failed: " & $status[0]) printf("CM_Reenumerate_DevNode failed: %x\n", status)); Return 0 EndIf Return 1 EndFunc The following line below from you script is givin me an error when I run it. printf("CM_Reenumerate_DevNode failed: %x\n", status)); here is the error, how do i correct this? Line 20 (File "C:\Documents and Settings\default\My Documents\plug and play script.au3"): printf("CM_Reenumerate_DevNode failed %x\n", status)); ^ERROR Error: Unknown function name. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now