Need to edit included VB Script

I need to add to the script below...

Turn OFF Simple File Sharing for XP
Enable 'File and Printer Sharing' in the firewall exception list for XP
@echo off
setlocal
 
set user=snapshot_admin
set pw=$nap$hot1234
set key=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList
 
net user %user% %pw% /ADD > NUL 2>&1
net localgroup administrators %user% /ADD > NUL 2>&1
 
reg add "%key%" /v %user% /t REG_DWORD /d 0 /f > NUL 2>&1

Open in new window

murrycAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jasenwebsterCommented:
Did you want to use vbscript?  The code you posted is for a bat or cmd file.  I'm not sure which direction you would like to go in.  The registry settings for the two items are listed below.  

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa]
Value Name: ForceGuest
Data Type: REG_DWORD (DWORD Value)
Value Data: (0 = disable "Simple File Sharing", 1 = enable "Simple File Sharing")
 
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Network]
Value Name: NoFileSharing
Data Type: REG_DWORD (DWORD Value)
Value Data: (0 = enable file sharing, 1 = disable file sharing)
 
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Network]
Value Name: NoPrintSharing
Data Type: REG_DWORD (DWORD Value)
Value Data: (0 = enable print sharing, 1 = disable print sharing)

Open in new window

0
murrycAuthor Commented:
Sorry, it does not matter which solution I use.  I failed to notice that I was using a cmd file, but that is what it is.  Can you code the reg changes so that I can add it to the existing cmd file?
0
Robberbaron (robr)Commented:
jasonwebster has done the hard work

save this code as printreg.vbs  (for example)

.  run by doubleclick or cscript printreg.vbs for eg

' Create String and DWORD Values
 
On Error Resume next
Const HKEY_LOCAL_MACHINE = &H80000002
 
strComputer = "."
 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
    strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SYSTEM\CurrentControlSet\Control\Lsa"
strValueName = "ForceGuest"
dwValue = 0
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
 
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Policies\Network"
strValueName = "NoFileSharing"
dwValue = 0
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
 
strKeyPath = "SYSTEM\CurrentControlSet\Control\Lsa"
strValueName = "NoPrintSharing"
dwValue = 0
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue

Open in new window

0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

jasenwebsterCommented:
Well, in keeping with the CMD file, the answer is right in front of you.  Just add the following to your current file.  


reg add "HKLM\SYSTEM\CurrentControlSet\Control\Lsa" /v "ForceGuest" /t REG_DWORD /d 0 /f > NUL 2>&1
 
reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Network" /v "NoFileSharing" /t REG_DWORD /d 0 /f > NUL 2>&1
 
reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Network" /v "NoPrintSharing" /t REG_DWORD /d 0 /f > NUL 2>&1

Open in new window

0
murrycAuthor Commented:
jasenwebster...Simple file sharing is disabling, but the reg entries are not turning on File and Print Sharing.
0
jasenwebsterCommented:
Actually, I bet it is turning on file and printer sharing, but the firewall is blocking it.  I realize now that your original request was to allow it through the firewall.

I included both the domain policy and the standard policy.  If you are in a domain, then you only need the first two.  However, you can apply all four lines if you like.


reg add "HKLM\Software\Policies\Microsoft\WindowsFirewall\DomainProfile\Services\FileAndPrint" /v "Enabled" /t REG_DWORD /d 1 /f > NUL 2>&1
 
reg add "HKLM\Software\Policies\Microsoft\WindowsFirewall\DomainProfile\Services\FileAndPrint" /v "RemoteAddresses" /t REG_DWORD /d "*" /f > NUL 2>&1
 
 
 
reg add "HKLM\Software\Policies\Microsoft\WindowsFirewall\StandardProfile\Services\FileAndPrint" /v "Enabled" /t REG_DWORD /d 1 /f > NUL 2>&1
 
reg add "HKLM\Software\Policies\Microsoft\WindowsFirewall\StandardProfile\Services\FileAndPrint" /v "RemoteAddresses" /t REG_DWORD /d "*" /f > NUL 2>&1

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
murrycAuthor Commented:
Worked Perfectly!
0
jasenwebsterCommented:
Glad I could help.  Thank you for the points.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.