metho Posted June 25, 2009 Share Posted June 25, 2009 Hi, I have been working on following batch for over two weeks now after watching Elder-n00b's php scrpit that does the same thing, which i tried but i could get anywhere with it. anyway cut long story short, i got it working (well sort of) using good old MS-DOS batching script. The problem is that i need to change some prameters which will make this script better, to be honest guys, you would be doing me a big favour if you could help me change 2 little things. ;) I'll highlight the bits where i need your help. thanks @echo off echo computer name changer! set /p name=your computername: reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ActiveComputerName" /v ComputerName /t reg_sz /d %name% /f >nul 2>nul reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v "NV Hostname" /t reg_sz /d %name% /f >nul 2>nul reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v Hostname /t reg_sz /d %name% /f >nul 2>nul echo. echo computername is changed pause > nul echo echo change workgroup name now! set /p name=your workgroupname: [i]"would this work with netdom, would it give me an option where i can specify the workgroup (during the installation/run process of the script) name rather typing below which would stay the same for all the systems."[/i] netdom.exe member /joinworkgroup MSHOME echo work done pause > nul echo set varip=192.168.1.65 "is there a way i can change these last two octets during the run process of the script" set varsm=255.255.255.0 set vargw=192.168.1.254 set vardns1=192.168.1.254 set vardns2=192.168.2.254 ECHO First draft of IP Changer! ECHO Setting IP Address and Subnet Mask netsh int ip set address name = "Local Area Connection" source = static addr = %varip% mask = %varsm% ECHO Setting Gateway netsh int ip set address name = "Local Area Connection" gateway = %vargw% gwmetric = 1 ECHO Setting Primary DNS netsh int ip set dns name = "Local Area Connection" source = static addr = %vardns1% ECHO Setting Secondary DNS netsh int ip add dns name = "Local Area Connection" addr = %vardns2% rem ECHO Here are the new settings for %computername%: rem netsh int ip show config pause echo. is there anyway i can make this script better or incorpate with a different programming Lang i.e. VB. thanks Quote Link to comment Share on other sites More sharing options...
dw5304 Posted June 26, 2009 Share Posted June 26, 2009 u can allways use vb.net. and call them though that... Dim myProcess2 As Process = New Process Dim s2 As String myProcess2.StartInfo.FileName = file name here myProcess2.StartInfo.UseShellExecute = False myProcess2.StartInfo.CreateNoWindow = True myProcess2.StartInfo.RedirectStandardInput = True myProcess2.StartInfo.RedirectStandardOutput = True myProcess2.StartInfo.RedirectStandardError = True myProcess2.StartInfo.Arguments = "" myProcess2.Start() Dim sIn2 As StreamWriter = myProcess2.StandardInput sIn2.AutoFlush = True Dim sOut2 As StreamReader = myProcess2.StandardOutput Dim sErr2 As StreamReader = myProcess2.StandardError s2 = sOut2.ReadToEnd() If Not myProcess2.HasExited Then myProcess2.Kill() End If sIn2.Close() sOut2.Close() sErr2.Close() myProcess2.Close() Quote Link to comment Share on other sites More sharing options...
metho Posted June 26, 2009 Author Share Posted June 26, 2009 hi, First of all, THANKS for replying, i must have checked this section of thread about 100 times today , waiting for a reply. <_< anyway looks like you know what you are talking about but i do not have a clue about vb.net or any other language etc. So if you dont mind, could you please elaberate or show me what to do and where to go etc. thanks in advance and thanks just for reading the thread. PS: come on guys, 59 hits and only one reply :( , come on, help a brother out here. ;) ;) Quote Link to comment Share on other sites More sharing options...
dw5304 Posted June 29, 2009 Share Posted June 29, 2009 simplest solution to make a sub and call the commands u want to run. I was assuming that u wanted a nice gui front end yes? example of usage. exec("cmd.exe", "-i") Public Sub exec (exe As String, args as string) Dim myProcess2 As Process = New Process Dim s2 As String Dim e2 As String myProcess2.StartInfo.FileName = exe myProcess2.StartInfo.UseShellExecute = False myProcess2.StartInfo.CreateNoWindow = True myProcess2.StartInfo.RedirectStandardInput = True myProcess2.StartInfo.RedirectStandardOutput = True myProcess2.StartInfo.RedirectStandardError = True myProcess2.StartInfo.Arguments = args myProcess2.Start() Dim sIn2 As StreamWriter = myProcess2.StandardInput sIn2.AutoFlush = True Dim sOut2 As StreamReader = myProcess2.StandardOutput Dim sErr2 As StreamReader = myProcess2.StandardError s2 = sOut2.ReadToEnd() e2 = sErr2.ReadToEnd() Console.WriteLine(s2) if e2 = nothing then else Console.WriteLine("Errors occured:" & e2) end if If Not myProcess2.HasExited Then myProcess2.Kill() End If sIn2.Close() sOut2.Close() sErr2.Close() myProcess2.Close() End Sub Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.