Startup/Logon to import regisrty

Hi ,

I have written the following script to import registry values, but its not working as startup or logon script.

Help me out.
Here is the code:


Thanks.
valuelabs97Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

AsokkumarCommented:
where is the code??? lol
0
FemSteenkampIT managerCommented:
download a tool called REGINI
you can then in a batch pass it a normel .reg file to add to the registry.
use this is a startup script ( it will run as local system and have needed permissions to make entries.
0
valuelabs97Author Commented:
Hi

Here is the code

@echo off
cls
if not exist c:\vlogo\disprn.reg (
cd\
c:
CD\
if not exist c:\vlogo MD VLOGO
net use M: \\bdc\scr
COPY M:\disprn.reg C:\VLOGO\
net use M: /delete
)
reg import c:\VLOGO\disprn.reg
EXIT
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

cyberlopez6Commented:
As a STARTUP script (computer security context), the drive mapping will fail unless you add the EVERYONE group to the NTFS & Share permissions with at least READ permissions.

As a LOGIN script (user's security context), the user would have to also have permissions to map the drive, but also have a minimum of Modify permissions on C:\ to create the directory.

I assume that you tested this batch file by running it manually, correct?
0
cyberlopez6Commented:
also, as a LOGIN script, the User would need to have permission to the portion of the registry that the REG file is importing to.  If this is HKCU, than its a non-issue, but will ONLY work in a LOGIN script, not a STARTUP script since there is no HKCU until the user logs in..  If its importing into HKLM than the user would need to be an Administrator.  If they are not, then STARTUP script will be your only option.
0
valuelabs97Author Commented:
Hi,

Thanks for your update.
we are importing to HKLM, in this how can I do it. Can I use run as command.
0
cyberlopez6Commented:
If the users are not local Administrators, then your best best is to run it as a STARTUP script.  Startup scripts run under the Computer accounts security context and will have full access to the local machine.

In order for the startup script to map a network drive, you may need to add the EVERYONE group to have read permissions.

However, if you are just making registry entries, you may be better off with a VBScript...  i'll post an example in a moment.
0
cyberlopez6Commented:
Here's an example script.  You should be able to make your own from these examples, or you can post the contents of your .reg file.

' variables for easier reading in command
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_CURRENT_USER = &H80000001

' create objREG object for writing to the registry
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")

' create the key, if necessary
strKeyPath = "Software\Policies\Microsoft\Office\11.0\Outlook\Options\Mail\"
objReg.CreateKey HKEY_CURRENT_USER,strKeyPath

'set a STRING value in HKey_Current_User
strKeyPath = "Software\Policies\Microsoft\Office\11.0\Outlook\Options\Mail\"
strEntryName = "JunkMailSafeSendersFile"
strValue = "\\server\netlogon\safesenders\safesenders.txt"
objReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strEntryName,strValue

'set a DWORD value in HKey_Local_Machine
strKeyPath = "Software\Microsoft\SomeRegKey\"
strEntryName = "SomeBogusValue"
strValue = 1
objReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

Open in new window

0
valuelabs97Author Commented:
Hi

Here is the registry file.

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,04,00,00,00,2A,E0,37,E0,00,00,37,E0,00,00,54,00,00,00,00,00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout\DosKeybCodes]
"00000402"="bg"
"00000404"="ch"
"00000405"="cz"
"00000406"="dk"
"00000407"="gr"
"00000408"="gk"
"00000409"="us"
"0000040A"="sp"
"0000040B"="su"
"0000040C"="fr"
"0000040E"="hu"
"0000040F"="is"
"00000410"="it"
"00000411"="jp"
"00000412"="ko"
"00000413"="nl"
"00000414"="no"
"00000415"="pl"
"00000416"="br"
"00000418"="ro"
"00000419"="ru"
"0000041A"="yu"
"0000041B"="sl"
"0000041C"="us"
"0000041D"="sv"
"0000041F"="tr"
"00000422"="us"
"00000423"="us"
"00000424"="yu"
"00000425"="et"
"00000426"="us"
"00000427"="us"
"00000804"="ch"
"00000807"="sg"
"00000809"="uk"
"0000080A"="la"
"0000080C"="be"
"00000813"="be"
"00000816"="po"
"00000C0C"="cf"
"00000C1A"="us"
"00001009"="us"
"0000100C"="sf"
"00001809"="us"
"00010402"="us"
"00010405"="cz"
"00010407"="gr"
"00010408"="gk"
"00010409"="dv"
"0001040A"="sp"
"0001040E"="hu"
"00010410"="it"
"00010415"="pl"
"00010419"="ru"
"0001041B"="sl"
"0001041F"="tr"
"00010426"="us"
"00010C0C"="cf"
"00010C1A"="us"
"00020408"="gk"
"00020409"="us"
"00030409"="usl"
"00040409"="usr"
"00050408"="gk"

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout\DosKeybIDs]
"00000410"="141"
"0000041F"="179"
"00010408"="220"
"00010410"="142"
"00010415"="214"
"0001041F"="440"
"00020408"="319"
0
cyberlopez6Commented:
Here you go...
Const HKEY_LOCAL_MACHINE = &H80000002
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")


strKeyPath = "SYSTEM\CurrentControlSet\Control\Keyboard Layout"
strValueName = "Scancode Map"
strBinaryArr = Array(0,0,0,0,0,0,0,0,4,0,0,0,42,224,55,224,0,0,55,224,0,0,84,0,0,0,0,0)
ret = objReg.SetBinaryValue(HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strBinaryArr)

strKeyPath = "SYSTEM\CurrentControlSet\Control\Keyboard Layout\DosKeybCodes"

strEntryName = "00000402"
strValue = "bg"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000404"
strValue = "ch"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000405"
strValue = "cz"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000406"
strValue = "dk"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000407"
strValue = "gr"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000408"
strValue = "gk"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000409"
strValue = "us"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "0000040A"
strValue = "sp"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "0000040B"
strValue = "su"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "0000040C"
strValue = "fr"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "0000040E"
strValue = "hu"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "0000040F"
strValue = "is"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000410"
strValue = "it"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000411"
strValue = "jp"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000412"
strValue = "ko"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000413"
strValue = "nl"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000414"
strValue = "no"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000415"
strValue = "pl"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000416"
strValue = "br"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000418"
strValue = "ro"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000419"
strValue = "ru"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "0000041A"
strValue = "yu"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "0000041B"
strValue = "sl"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "0000041C"
strValue = "us"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "0000041D"
strValue = "sv"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "0000041F"
strValue = "tr"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000422"
strValue = "us"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000423"
strValue = "us"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000424"
strValue = "yu"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000425"
strValue = "et"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000426"
strValue = "us"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000427"
strValue = "us"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000804"
strValue = "ch"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000807"
strValue = "sg"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000809"
strValue = "uk"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "0000080A"
strValue = "la"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "0000080C"
strValue = "be"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000813"
strValue = "be"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000816"
strValue = "po"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000C0C"
strValue = "cf"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00000C1A"
strValue = "us"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00001009"
strValue = "us"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "0000100C"
strValue = "sf"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00001809"
strValue = "us"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00010402"
strValue = "us"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00010405"
strValue = "cz"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00010407"
strValue = "gr"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00010408"
strValue = "gk"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00010409"
strValue = "dv"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "0001040A"
strValue = "sp"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "0001040E"
strValue = "hu"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00010410"
strValue = "it"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00010415"
strValue = "pl"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00010419"
strValue = "ru"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "0001041B"
strValue = "sl"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "0001041F"
strValue = "tr"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00010426"
strValue = "us"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00010C0C"
strValue = "cf"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00010C1A"
strValue = "us"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00020408"
strValue = "gk"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00020409"
strValue = "us"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00030409"
strValue = "usl"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00040409"
strValue = "usr"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00050408"
strValue = "gk"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue


strKeyPath = "SYSTEM\CurrentControlSet\Control\Keyboard Layout\DosKeybIDs"

strEntryName = "00000410"
strValue = "141"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "0000041F"
strValue = "179"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00010408"
strValue = "220"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00010410"
strValue = "142"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00010415"
strValue = "214"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "0001041F"
strValue = "440"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

strEntryName = "00020408"
strValue = "319" 
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue

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
valuelabs97Author Commented:
Good Solution
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
Active Directory

From novice to tech pro — start learning today.