?
Solved

Edit Proxy settings on a remote computer

Posted on 2009-02-24
26
Medium Priority
?
7,302 Views
Last Modified: 2013-11-09
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..
0
Comment
Question by:Mandev23
25 Comments
 
LVL 12

Expert Comment

by:nsx106052
ID: 23725834
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
 

Author Comment

by:Mandev23
ID: 23725864
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
 

Author Comment

by:Mandev23
ID: 23764459
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 66

Expert Comment

by:johnb6767
ID: 23765544
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
 

Author Comment

by:Mandev23
ID: 23765659
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
 

Author Comment

by:Mandev23
ID: 23765718
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
 
LVL 66

Expert Comment

by:johnb6767
ID: 23765721
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
 

Author Comment

by:Mandev23
ID: 23767427
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
 

Author Comment

by:Mandev23
ID: 23767452
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
 
LVL 66

Accepted Solution

by:
johnb6767 earned 2000 total points
ID: 23769068
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
 

Author Comment

by:Mandev23
ID: 23769296
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
 

Author Comment

by:Mandev23
ID: 23769317
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
 

Author Comment

by:Mandev23
ID: 23769388
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
 

Author Comment

by:Mandev23
ID: 23769400
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
 
LVL 66

Expert Comment

by:johnb6767
ID: 23769420
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
 

Author Comment

by:Mandev23
ID: 23769464
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
 
LVL 66

Assisted Solution

by:johnb6767
johnb6767 earned 2000 total points
ID: 23769478
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
 

Author Comment

by:Mandev23
ID: 23769542
ok, is there a way to check settings on a remote computer like if the proxy is in place?
using psexec
0
 
LVL 66

Expert Comment

by:johnb6767
ID: 23769564
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
 

Author Comment

by:Mandev23
ID: 23769594
true..
ok.. thanks for your help again John.
i'll see how this goes tommorrow...
0
 
LVL 66

Expert Comment

by:johnb6767
ID: 23769852
Good luck..., and I will be around in a limited capacity if needed.....
0
 

Author Comment

by:Mandev23
ID: 23773549
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
 
LVL 66

Expert Comment

by:johnb6767
ID: 23781371
Vista has HKEY_CURRENT_USERS as well.....

Where was proxy enable?
0
 
LVL 6

Expert Comment

by:Justin_W_Chandler
ID: 24167855
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
 
LVL 66

Expert Comment

by:johnb6767
ID: 24174176
That works GREAT if they are administrators of the machines........
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Measuring Server's processing rate with a simple powershell command. The differences in processing rate also was recorded in different use-cases, when a server in free and busy states.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
Suggested Courses
Course of the Month14 days, 17 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question