Jump to content

.bat HELP


Fiziks
 Share

Recommended Posts

Hey, I was planning on creating a .bat that will disable the net connection and "%windir%\system32\rundll32.exe user32.dll, LockWorkStation" and another that will enable the connection..

i need some sort of code template, or at least the second and third commands respectively. anybody??!!

Link to comment
Share on other sites

To stop the connection you could use:

sc \\machine_name stop dhcp

To start it back up:

sc \\machine_name start dhcp

For \\machine_name you would put your own, which can be found by right clicking My Computer and going to properties. Then go to the Computer Name tab. The command just stops the DHCP service, taking the ip address away as the result. If you don't like this method I'm sure there are more to be found, this is just how I would do it. Is this what you wanted?

Link to comment
Share on other sites

ok i have new question..

I created a .bat (Lock.bat) with

@echo off

CALL D:\TEMP\bat-nttmp\killnet.bat

start /MIN /HIGH /B C:\WINDOWS\system32\rundll32.exe user32.dll, LockWorkStation

exit

and a .bat (D:\TEMP\bat-nttmp\killnet.bat) containing:

@echo off

start /B C:\WINDOWS\system32\sc.exe \\II stop dhcp

upon opening [Lock.bat] the workstation locks yet the net still stays connected, wtf have I done?!!?

(II is the name of the sys, btw)

killnet works alone

when i click it, all's well

but the call from "lock.bat" isn't working...

also, sometimes I get an error messages when attempting to sc \\xx stop dhcp saying <failed> because dependencies rely on this, is there a way I can override this?

Link to comment
Share on other sites

Heres what I made and it seems to work for me.

killnet.bat

@echo off

sc \\emachine stop dhcp

call C:\docume~1\owner\desktop\lockme.bat

lock.bat

rundll32.exe user32.dll, LockWorkStation

You can always use the && operator between commands so if the first command executes successfully then the second will or the net stop dhcp command. I'm not sure how you can force them dependencies off though. If I see anything on the net I'll post back.

Link to comment
Share on other sites

Heres what I made and it seems to work for me.

killnet.bat

@echo off

sc \\emachine stop dhcp

call C:\docume~1\owner\desktop\lockme.bat

lock.bat

rundll32.exe user32.dll, LockWorkStation

You can always use the && operator between commands so if the first command executes successfully then the second will or the net stop dhcp command. I'm not sure how you can force them dependencies off though. If I see anything on the net I'll post back.

...

killnet.bat

@echo off

sc \\system_name stop dhcp

call C:\docume~1\owner\desktop\LOCK.bat

LOCK.bat

rundll32.exe user32.dll, LockWorkStation

"sc \\system_name stop dhcp" this doesn't work, not alone or in conjunction...

er, don't you have to type "start" to execute a command

and i tried...

killnet.bat

@echo off

start sc \\system_name stop dhcp

call C:\docume~1\owner\desktop\LOCK.bat

LOCK.bat

rundll32.exe user32.dll, LockWorkStation

locks, but the bits are still streaming between myself and my isp...

I'm using server 2003..

thanks, btw

Link to comment
Share on other sites

You should not have to enter the "start" command before a command. The only reason you would is if C:\windows\system32 is not in your system environment. To see if it is enter the command "path" without the quotes. It should display a couple different directories but you'll want C:\windows\system32 in there. If it isn't just type "path ;C:\WINDOWS\system32" in without the quotes to add it or right-click on My Computer, properties, Advanced tab, Environment Variables button, and add it to the system variables.

Also, how do you know the bits are still streaming?

Link to comment
Share on other sites

You should not have to enter the "start" command before a command. The only reason you would is if C:\windows\system32 is not in your system environment. To see if it is enter the command "path" without the quotes. It should display a couple different directories but you'll want C:\windows\system32 in there. If it isn't just type "path ;C:\WINDOWS\system32" in without the quotes to add it or right-click on My Computer, properties, Advanced tab, Environment Variables button, and add it to the system variables.

Also, how do you know the bits are still streaming?

here

nettl.JPG

it still doesn't work, with or without start, arrrrggh

Link to comment
Share on other sites

Thats wierd. I didn't have that problem on xp home or server 2003 enterprise. That service can be disabled for good if your not using a proxy server to download your windows updates. You could add something like this to your batch file.

sc \\II config winhttpautoproxysvc start= disable

To start it back up, it would be sc \\II config winhttpautoproxysvc start= demand

There has to be a space after the = sign

or stopping that service if its already started will work, like this

net stop winhttpautoproxysvc && net stop dhcp

To start it back up, it would be net start dhcp && net start winhttpautoproxysvc

Link to comment
Share on other sites

sc \\II config winhttpautoproxysvc start= disable

To start it back up, it would be sc \\II config winhttpautoproxysvc start= demand

There has to be a space after the = sign

or stopping that service if its already started will work, like this

net stop winhttpautoproxysvc && net stop dhcp

To start it back up, it would be net start dhcp && net start winhttpautoproxysvc

I tried...

net stop winhttpautoproxysvc && net stop dhcp

it said service failed to shut down..

...I tried disabling the service altogether, I then tried "net stop dhcp".. it stopped the connection but when I tried to start it (net start dhcp) again it failed...

i checked connection settings, repair failed, disable/enable failed...

noip.JPG

then after a logoff/login still no connection...

dnsfailed.JPG

restart resolved connection again...

can i debug this?!?!?

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.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy