Edit Proxy settings on a remote computer

Hi

I was given this code on experts exchange:
@echo off
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t reg_dword /d 00000001 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t reg_sz /d "w2k3rti03:8080" /f
reg add "HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings" /d "Security_HKLM_only" /t reg_dword /v 00000001 /f
exit

It enables the proxy for a remote computer, executed from my own laptop with the aid of PsTools.
C:\>Pstools\>psexec.exe \\remote_pc_name -c -d IEReg.bat

However it doesnt seem to be working now, i changed my laptop, got PsTools in the C: along with the IEReg.bat file...? it works if i run it for my own pc but not a remote one? Any suggestions?

Also is there a way this script can be executed using a scheduled task, without prompting the user to authorise/action the prompt..
Mandev23Asked:
Who is Participating?
 
johnb6767Commented:
Let me explain further....

You have the following....

PC1, and PC2
PC1 has John logged on
PC2 has Bob logged on.

John runs the following from PC1

psexec.exe \\PC2 -c -d IEReg.bat

It will not set the proxy under HKCU for bob, because the command is running under John's profile, which means it will merge to John's HKCU (c:\docs and settings\john\ntuser.dat).......

Try the suggestion on a single regular user from 23765544. If it works, lets just uyse psexec to deploy the batch file out to all machines.....
0
 
nsx106052Commented:
Copy the script to the other computer and then log in as an admin and create a scheduled task to run the script.  TO create a schedule task go the the control panel and select scheduled task.  From there just follow the wizard.
0
 
Mandev23Author Commented:
but when the script run, the user is prompted whether they want to ammend the registry with these settings (yes/no), a scheduled task wont cater for this, i tried it earlier and the task just continuously said ..running

My main issue is the script not working at the moment, can you test it please on a remote pc?
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
Mandev23Author Commented:
hi nsx

what you are suggesting i have already tried and is not working... but this is besides the point, forget running it as a task for now...

the actual execution of the script doesnt work??
C:\>Pstools\>psexec.exe \\remote_pc_name -c -d IEReg.bat
when i specify a remote pc name, it says its executed fine, but there is no change on the proxy
- this is what i would like the experts to test please.!!
0
 
johnb6767Commented:
Put it in a logon script.
Just these 2.....

@echo off
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t reg_dword /d 00000001 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t reg_sz /d "w2k3rti03:8080" /f

Save it as logon.bat

Even a limited user should have rights to that portion of the profile, as long as there are no othert policies in place to restrict it...

PS, I thought this looked familiar. I reviewed the last thread, and saw where the local machine wasnt working for IE7.....

Please advise if this doesnt work...
0
 
Mandev23Author Commented:
hi john

good to hear from you again..
Remember we had this working, however i've changed laptops but when i log in as admin, the script no longer executes on a remote pc? it says its done it but...?

so this time just use the two command lines using
C:\>Pstools\>psexec.exe \\remote_pc_name -c -d IEReg.bat  

??
0
 
Mandev23Author Commented:
hi john
no the two lines you gave do not work...?
it says its executed but no result on the remote pc?
the proxy does not enable...

0
 
johnb6767Commented:
but remember, it will modify the registry of the user RUNNING psexec , not the one you are targeting...

Thats why it worked under HKLM, but not under HKCU.

0
 
Mandev23Author Commented:
i dont understand that, it worked as HKCU before...  it enabled the proxy on the remote pc...

gues i could try is as HKLM again...?
0
 
Mandev23Author Commented:
as you know
HKLM does not have the option for setting the proxy:
reg add "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Internet Settings"  ProxyEnable?
- its only in HKCU...

When i put my machine name in this it works?? but not a remote pc
C:\>Pstools\>psexec.exe \\remote_pc_name -c -d IEReg.bat  
0
 
Mandev23Author Commented:
oh right ok..

shall i not use psexec at this stage then?
Just save:
@echo off
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t reg_dword /d 00000001 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t reg_sz /d "w2k3rti03:8080" /f

as a logon.bat file, and execute on the remote pc itself?
0
 
Mandev23Author Commented:
John

I saved the script as a logon.bat file, ran it on a remote computer itself and it worked. The proxy enabled.
- how can i now use psexec to remotely enable the proxy for a remote pc?
- or do i place the logon.bat file in the ADUC profile path? so it runs when they log on (always)
0
 
Mandev23Author Commented:
i think its sorted...
I added the 2 lines to my current user logon script, and it discreetly enables the proxy. Perfect!
Although i have hidden the connections tab, so users cannot change it, the script should still run ok...
0
 
Mandev23Author Commented:
John
just one question though...

we originally spoke of Psexec, so where does the command you showed me fit into this?
C:\>Pstools\>psexec.exe \\remote_pc_name -c -d IEReg.bat  

?
0
 
johnb6767Commented:
You can use it to modify HKLM entries on the remote machine with no problem, think the main thing was that IE7 didnt like the HKLM_Security_Only value......

Other things work well for psexec as well....

psexec \\remotepc cmd.exe, open a cmd prompt on your machine, but it physically is a remote cmd shell... You can view system info, use other reg add, reg query commands etc....

very powerful tool.

I wasnt sure if you already had a logon script, so we were going to create a simple one, and deploy it using psexec using a simple copy command... You can run almost ANY command as you would locally, on a remote PC using psexec, but you have to be aware of the environment on the remote one.

psexec \\remotepc copy s:\folder\file.txt c:\newfolder\file.txt wouldnt work if bob was logged on with an S drive, because your proifile may not ave it mapped....  

Make sense?
0
 
Mandev23Author Commented:
I just added the lines to our current logon policy... seems to have worked fine. I like it because it requires no user input or action to authorise the change. Do you remember we created a similar script before using .reg files, they prompted the user with yes/no to authorise the change in the reg file....?

wow, that sounds awesome!
so, in affect i could type psexec \\remotepc cmd.exe, and see information on that remote pc from my computer? without logging on it? test pings etc..?

you will have to send me a list of useful commands i could use to check sys information etc.

i would like to experiment...
0
 
johnb6767Commented:
DOS is a fun place to live in still.....

Tracert
pathping
systeminfo (gives system uptime, processor, swap file updates etc....)
net.exe (net use, net view, net user etc...)

Really anything you normally do to troubleshoot a problem locally, you can do with psexec.
0
 
Mandev23Author Commented:
ok, is there a way to check settings on a remote computer like if the proxy is in place?
using psexec
0
 
johnb6767Commented:
Not by querying an HKCU value......

Unless you know thier SID, which is more trouble than it's worth..... Faster to use Remote Registry, and look under the HKEY_Users hive...

 
0
 
Mandev23Author Commented:
true..
ok.. thanks for your help again John.
i'll see how this goes tommorrow...
0
 
johnb6767Commented:
Good luck..., and I will be around in a limited capacity if needed.....
0
 
Mandev23Author Commented:
for whatever reason i dont think the script ran on the vista pc, is it because in regedit they dont have HKCU but rather HKEY_USERS ? different abbreviation

i cant find 'ProxyServer' setting in regedit on a vista pc?
i found ProxyEnable

0
 
johnb6767Commented:
Vista has HKEY_CURRENT_USERS as well.....

Where was proxy enable?
0
 
Justin_W_ChandlerCommented:
Why is everyone making this so difficult? All you have to do is modify the registry from the system you're on. Use the code below to make a SETUPPROXY.CMD batch file and then run it like this:

SETUPPROXY.CMD [NAME_OF_SERVER]

Examples: SETUPPROXY.CMD ANUBIS
                 SETUPPROXY.CMD MORPHEUS.SOMEDOMAIN.COM
                 SETUPPROXY.CMD 10.13.21.45

REMEMBER: If a user is logged on when you run this, they may have to log off and back on for it to work. You can alternatively try ending task on explorer.exe and restarting it (must also have all browser windows closed)

Justin Chandler
reg add "\\%1\HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t reg_dword /d 00000001 /f
reg add "\\%1\HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t reg_sz /d "w2k3rti03:8080" /f
reg add "\\%1\HKLM\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings" /d "Security_HKLM_only" /t reg_dword /v 00000001 /f

Open in new window

0
 
johnb6767Commented:
That works GREAT if they are administrators of the machines........
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.