Solved

Logon Script Brain Cramp

Posted on 2006-07-14
4
311 Views
Last Modified: 2010-08-05
I am having a bit of a brain cramp on my scripting abilities.

-------------------------------------------------------------------------------------------------

Below is the contents of a .reg file that is normally used to create a registry entry for users for a program we use. This has to be done for the logged on use.

[HKEY_CURRENT_USER\Software\Lilly Software\VISUAL Manufacturing\Configuration]
"Local Directory"="c:\\VISUAL\\vmfg_ini"
--------------------------------------------------------------------------------------------------

Below is the contents of a .vbs script I wrote to do the same as the above .reg file. Am I on the right path with my thinking?

This registry edit/entry is going to be used for Windows 2000 Pro, XP Pro, and Windows 2003 Terminal Server Clients.

 
Const HKEY_CURRENT_USER = &H80000002
strComputer = "."

Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "Software\Lilly Software\VISUAL Manufacturing\Configuration"
strValueName = "Local Directory"
strValue = "%c:\VISUAL\vmfg_ini%"

objReg.SetExpandedStringValue _
    HKEY_CURRENT_USER,strKeyPath,strValueName,strValue

---------------------------------------------------------------------------------------------------------------

TIA
Dave
0
Comment
Question by:TheMetrix
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 26

Expert Comment

by:Pber
ID: 17107777
Instead of writing it in VB, why not just batch out the reg file

regedit -s YourRegfile.reg

You could also do the same thing with reg.exe
reg add "HKCU\Software\Lilly Software\VISUAL Manufacturing\Configuration" /v "Local Directory" /t REG_SZ /d c:\VISUAL\vmfg_ini /f


0
 
LVL 26

Expert Comment

by:Pber
ID: 17107898
If you really want to do it in VB:

Const HKEY_CURRENT_USER = &H80000001  '<- changed this to 1 from 2
strComputer = "."

Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "Software\Lilly Software\VISUAL Manufacturing\Configuration"
strValueName = "Local Directory"
strValue = "c:\VISUAL\vmfg_ini"  '<- removed the '%'

objReg.CreateKey(HKEY_CURRENT_USER, strKeyPath) ' <- added this - you must create the key first

objReg.SetExpandedStringValue _
    HKEY_CURRENT_USER,strKeyPath,strValueName,strValue
0
 
LVL 26

Accepted Solution

by:
Pber earned 125 total points
ID: 17107937
I've modified it slightly once again since I removed the return value from the CreateKey and thus must also remove the parentheses.

Anyhow, this should work good:

Const HKEY_CURRENT_USER = &H80000001  '<- changed this to 1 from 2
strComputer = "."

Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "Software\Lilly Software\VISUAL Manufacturing\Configuration"
strValueName = "Local Directory"
strValue = "c:\VISUAL\vmfg_ini"  '<- removed the '%'

objReg.CreateKey HKEY_CURRENT_USER, strKeyPath  ' <- added this - you must create the key first

objReg.SetStringValue  HKEY_CURRENT_USER,strKeyPath,strValueName,strValue   '<- changed from Expanded to Just String.
0
 
LVL 5

Author Comment

by:TheMetrix
ID: 17108349
Pber,

The reason for not wanting to run the .reg file through a .bat script is I don't want users to see the script run and give them the chance to possibly cancel.

I used the second post to create the .vbs script, it works perfectly.

Thank you very much.

Points Awarded.
0

Featured Post

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

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

This may not be a text book method to resolve VSS backup issues but it seemed to have worked on few of the Windows 2003 servers we had issues while performing a Volume Shadow Copy backup. If you have issues while performing a shadow copy backup usin…
Scenerio: You have a server running Server 2003 and have applied a retail pack of Terminal Server Licenses.  You want to change servers or your server has crashed and you need to reapply the Terminal Server Licenses. When you enter the 16-digit lic…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

688 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