Jump to content

Batch file HELP!!


metho

Recommended Posts

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. :angry: anyway cut long story short, i got it working (well sort of) using good old MS-DOS batching script. :rolleyes: 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 :rolleyes::rolleyes:

Link to comment
Share on other sites

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()

Link to comment
Share on other sites

hi, :rolleyes:

First of all, THANKS for replying, :rolleyes: i must have checked this section of thread about 100 times today :blink: , 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. ;) ;)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...