TheMetrix
asked on
Logon Script Brain Cramp
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\Softwar e\Lilly Software\VISUAL Manufacturing\Configuratio n]
"Local Directory"="c:\\VISUAL\\vm fg_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 :{imperson ationLevel =impersona te}!\\" & _
strComputer & "\root\default:StdRegProv" )
strKeyPath = "Software\Lilly Software\VISUAL Manufacturing\Configuratio n"
strValueName = "Local Directory"
strValue = "%c:\VISUAL\vmfg_ini%"
objReg.SetExpandedStringVa lue _
HKEY_CURRENT_USER,strKeyPa th,strValu eName,strV alue
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -----
TIA
Dave
--------------------------
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\Softwar
"Local Directory"="c:\\VISUAL\\vm
--------------------------
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
strComputer & "\root\default:StdRegProv"
strKeyPath = "Software\Lilly Software\VISUAL Manufacturing\Configuratio
strValueName = "Local Directory"
strValue = "%c:\VISUAL\vmfg_ini%"
objReg.SetExpandedStringVa
HKEY_CURRENT_USER,strKeyPa
--------------------------
TIA
Dave
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 :{imperson ationLevel =impersona te}!\\" & _
strComputer & "\root\default:StdRegProv" )
strKeyPath = "Software\Lilly Software\VISUAL Manufacturing\Configuratio n"
strValueName = "Local Directory"
strValue = "c:\VISUAL\vmfg_ini" '<- removed the '%'
objReg.CreateKey(HKEY_CURR ENT_USER, strKeyPath) ' <- added this - you must create the key first
objReg.SetExpandedStringVa lue _
HKEY_CURRENT_USER,strKeyPa th,strValu eName,strV alue
Const HKEY_CURRENT_USER = &H80000001 '<- changed this to 1 from 2
strComputer = "."
Set objReg=GetObject("winmgmts
strComputer & "\root\default:StdRegProv"
strKeyPath = "Software\Lilly Software\VISUAL Manufacturing\Configuratio
strValueName = "Local Directory"
strValue = "c:\VISUAL\vmfg_ini" '<- removed the '%'
objReg.CreateKey(HKEY_CURR
objReg.SetExpandedStringVa
HKEY_CURRENT_USER,strKeyPa
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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.
regedit -s YourRegfile.reg
You could also do the same thing with reg.exe
reg add "HKCU\Software\Lilly Software\VISUAL Manufacturing\Configuratio