Windows Server 2003
1753925 Members
9562 Online
108810 Solutions
New Discussion юеВ

Re: vbs script to configure as a login script - plz help

 
SOLVED
Go to solution
Maaz
Valued Contributor

vbs script to configure as a login script - plz help

DC: win2k3 server
plz help me ... and provide me the code of a vbs script that can run the following command:

netsh interface ip set address name="Local Area Connection" source=dhcp

I have to configure the login script via group policy, in which the "netsh interface ip set ..." command runs, and set the machine, a dhcp client. I try by simply make "abc.vbs" file with the code "netsh interface ip set ...", but when I run/execute the file, it produce compilation error.

Regards
Maaz
7 REPLIES 7
Jonathan Axford
Trusted Contributor
Solution

Re: vbs script to configure as a login script - plz help

Hi,

You would probably be better off making a .cmd file and putting this in the logon script in group policy.

Simply coy the line :

netsh interface ip set address name="Local Area Connection" source=dhcp

into notepad and save it as LAN.cmd endsuring that you Local Area Connection is actually called Local Area Connection and not something else!

The set up the policy with this file and it should work ok....

:-)

Where there is a will there is a way...
Maaz
Valued Contributor

Re: vbs script to configure as a login script - plz help

Thanks Dear Jonathan Axford for help. I have not yet check your suggestion, but will be able to check/work on tomorrow, then I'll let you(forum) know the result.

May I ask one more thing...
abc.vbs is called a "vb script"
abc.bat is called a "batch file/scipt"
what will be abc.cmd called ?
Igor Karasik
Honored Contributor

Re: vbs script to configure as a login script - plz help

Maaz,
.bat and .cmd are same - no difference in behavior for windows NT/2000/XP/2003
However, windows 95/98 can work only with .bat files and not with .cmd


.BAT = common to x-DOS operating systems (for windows 95/98 for example)
.CMD = used by OS/2 and introduced first in Windows NT4



Maaz
Valued Contributor

Re: vbs script to configure as a login script - plz help

Thanks Igor for help ;)

Regards
Maaz
Gene Laoyan
Super Advisor

Re: vbs script to configure as a login script - plz help

Batch files and .cmd files are not eobust enough. Here a vbscript version....

strCommandLine = Chr(34) & "netsh interface ip set address name=" & Chr(34) & "Local Area Connection" & Chr(34) & "source=dhcp" & Chr(34)

Call ExecuteADOSCommand(strCommandLine)


Sub ExecuteADOSCommand(varCommandLine)
MsgBox varCommandLine
Dim oWshShell
Set oWshShell = CreateObject("WScript.Shell")
oWshShell.Run "%COMSPEC% /c " & Chr(34) & varCommandLine & Chr(34), 1, False
'True - Wait till commandline finishes before continuing through the script.
'False - Do not wait for the commandline finishes before continuing through the script.
'0 Hides the window and activates another window.
'1 Activates and displays a window. If the window is minimized or maximized,
' the system restores it to its original size and position. An application
' should specify this flag when displaying the window for the first time.
'2 Activates the window and displays it as a minimized window.
'3 Activates the window and displays it as a maximized window.
'4 Displays a window in its most recent size and position. The active window remains active.
'5 Activates the window and displays it in its current size and position.
'6 Minimizes the specified window and activates the next top-level window in the Z order.
'7 Displays the window as a minimized window. The active window remains active.
'8 Displays the window in its current state. The active window remains active.
'9 Activates and displays the window. If the window is minimized or maximized, the system
' restores it to its original size and position. An application should specify this flag
' when restoring a minimized window.
Set oWshShell = Nothing
End Sub
Phil.Howell
Honored Contributor

Re: vbs script to configure as a login script - plz help

Maaz
Valued Contributor

Re: vbs script to configure as a login script - plz help

Dear Mr Gene Laoyan Millions of Thanks for such a nice help.
Dear Mr Phil. Howell thanks for providing the superb resource(url).

Thanks EveryOne.
Regards
Maaz