Login | |
|
 |
RE: renew IP address in login script - 9/1/2005 3:57:14 AM
|
|
 |
|
| |
thantos_kalev2001
Posts: 26
Score: 0
Joined: 8/31/2005
Status: offline
|
You could call a command line in a vbscript and just use ipconfig/release and ipconfig/renew. For example: Set objShell = Wscript.CreateObject("Wscript.Shell") objShell.run("%comspec% /k ipconfig /release") objShell.run("%comspec% /k ipconfig /renew") Thantos Kalev
|
|
| |
|
|
|
 |
RE: renew IP address in login script - 9/1/2005 4:19:59 AM
|
|
 |
|
| |
mbouchard
Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
|
One thing to keep in mind, as soon as you release you will lose your connection to your netlogon share and there is a strong possibility that the script will not work properly. What I would recommend is this, create a script and save it in your netlogon share. This script would essentally do what thantos says below. Release the IP, renew the IP, then it would check for the login script, you can have a loop here that would check every few seconds. And once it can see the login script, it 1) writes a log file that is used by the login script, this would be used to prevent it from copying and running the ipconfig renew script again, 2) Runs the login script, and 3) deletes itself. Now, in your login script do something like this: If Tagfile doesn't exist Then Copy ip renew script to PC run ipscript quit End If Then when your sure all PC's have been renewed, you can change the code to delete the tag file if it does exist. One note, do not call the 2nd script ipconfig.vbs. It will not work properly as it will try to run the ipconfig.exe.
_____________________________
Mike For useful Scripting links see the Read Me First stickey! Always remember Search is your friend.
|
|
| |
|
|
|
 |
RE: renew IP address in login script - 9/2/2005 3:17:15 AM
|
|
 |
|
| |
thantos_kalev2001
Posts: 26
Score: 0
Joined: 8/31/2005
Status: offline
|
Try this code to get it to execute: WshShell.run("%comspec% /c c:\rapid.bat") And then this to delete the file locally: fso.DeleteFile "c:\rapid.bat" Cheers! Thantos
|
|
| |
|
|
|
 |
RE: renew IP address in login script - 9/2/2005 3:38:35 AM
|
|
 |
|
| |
mbouchard
Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
|
Try telling it where the cmd.exe is. Something like this. If fso.FileExists("c:\windows\system32\cmd.exe") then WshShell.Run "c:\windows\system32\cmd.exe /C c:\rapid.bat" ElseIf fso.FileExists("c:\winnt\system32\cmd.exe") then WshShell.Run "c:\winnt\system32\cmd.exe /C c:\rapid.bat" Else Msgbox "Something is wrong" End If I am just wondering if comspec is not working as the environment variables are not set/configured/whatever. Not sure of the timing.
_____________________________
Mike For useful Scripting links see the Read Me First stickey! Always remember Search is your friend.
|
|
| |
|
|
|
 |
RE: renew IP address in login script - 9/2/2005 3:47:38 AM
|
|
 |
|
| |
thantos_kalev2001
Posts: 26
Score: 0
Joined: 8/31/2005
Status: offline
|
Here is what I used to get it to work: Set network = WScript.CreateObject("WScript.Network") Set fso = WScript.CreateObject("Scripting.FileSystemObject") Set WshShell = Wscript.CreateObject("Wscript.Shell") WScript.Echo "Your IP Address will release and renew with this script" fso.CopyFile "\\networkpath", "C:\test\" WshShell.run("%comspec% /k c:\test\batFileName.bat") WScript.Sleep 2500 fso.DeleteFile "c:\test\batFileName.bat" I am pretty sure that you dont need the OPTION EXPLICIT or QUIT. I did not have luck getting it to copy the file to the local C drive, but it works if you copy it to a folder on the local drive, as I have shown in the above script. You might want to use what I have above, and just put in your server pah and .bat file name. Thantos
|
|
| |
|
|
|
 |
RE: renew IP address in login script - 9/2/2005 3:50:40 AM
|
|
 |
|
| |
thantos_kalev2001
Posts: 26
Score: 0
Joined: 8/31/2005
Status: offline
|
Mbouchard is right about the comspec...I am running windows Xp, but you might have a different path to the command line. Replacing %comspec% with cmd should work as well...I just used what works for me. Sorry for the confusion! Thantos
|
|
| |
|
|
|
 |
RE: renew IP address in login script - 9/2/2005 3:56:36 AM
|
|
 |
|
| |
Country73
Posts: 733
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
|
You should also be able to use: WshShell.run "cmd /c c:\test\batfileName.bat",0,True fso.DeleteFile "c:\test\batfileName.bat" Running it this way will hide the command window, wait for the batch file to complete before going to the next step. (which is deleteing the bat file) That way you don't run into some machines "hanging" and the script trying to delete the bat file before completion.
< Message edited by Country73 -- 9/2/2005 3:58:00 AM >
|
|
| |
|
|
|
 |
RE: renew IP address in login script - 9/6/2005 2:03:43 AM
|
|
 |
|
| |
thantos_kalev2001
Posts: 26
Score: 0
Joined: 8/31/2005
Status: offline
|
Have you tested your 2 script method? This looks like it should work. One caveat: My script stalls when I run the gpupdate/force command--I am prompted on whether or not I want to reboot, and it hangs my script. Maybe this is causing the problem with yours? You might want to just use gpupdate rather than gpupdate/force . Thantos
|
|
| |
|
|
|
 |
RE: renew IP address in login script - 9/7/2005 12:18:24 AM
|
|
 |
|
| |
thantos_kalev2001
Posts: 26
Score: 0
Joined: 8/31/2005
Status: offline
|
Yes, that will work. Just make sure that you have that .vbs file in the C directory! :) Thantos
|
|
| |
|
|
|
 |
RE: renew IP address in login script - 9/7/2005 1:24:01 AM
|
|
 |
|
| |
DiGiTAL.SkReAM
Posts: 1184
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
|
Do you really need to have a ipconfig/renew statement? Correct me if I am wrong, but if you do a ipconfig/release, and then reboot the workstation, will it not reach for a new IP via DHCP when it comes back on? If you are running the scripts on Windows Xp Pro boxen, you shoudl be able to just do this: (Lines in your login.bat) if not exist c:\IPChangeDone.Markfile xcopy \\server\share\rapid.cmd c:\ /y if exist c:\rapid.bat start %comspec% /c c:\rapid.cmd :EOF Then, your rapid.cmd file should contain: ipconfig/release echo. > c:\IPChangeDone.Markfile shutdown -r -t 10 -c "Workstation rebooting to facilitate network maintenance. Please Stand By" -f :EOF You would call the rapid.bat file from the login.bat as the very last thing that you do because as soona s you do, the network conenction would be lost. As you can see from above, the order of events is: 1.) If the log file is not present, it means that the job has not run, so go ahead nad copy rapid.bat over to C:\ 2.) if the rapid.bat file is present, run it. Conversely, if you would rather just do everything from one line in your login.bat, without having to reboot, or run external files, etc... you can use this command as the last one in your login.bat file: if not exist c:\IPChangeDone.Markfile ipconfig/release&&ipconfig/renew&&echo. > c:\IPChangeDone.Markfile&&shutdown -r -t 5 -f That way, if it doesn't find the mark file, it will release and renew the IP address, create the mark file, and then reboot the workstationw ith a five second delay. Hope this helps.
_____________________________
"Would you like to touch my monkey?" - Dieter (Mike Meyers) "It is better to die like a tiger, than to live like a pussy." -Master Wong, from Balls of Fury
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|