John45
(Fresh Scripter)
2007-08-10 03:15 PM
Specify a day of week to run (new code update)

Im brand new to KiXtart and have never done anything like this. I have been tasked with editing our current login script which is pretty basic (if in X group map X drive).

I need to set some registry settings and run a vbs script. I think I have all the code except i want to only run this registry part and vbs part on Tuesdays...

Thanks for any suggestions.

Here what was thinking. I integrated the registry settings into my .vbs so I was wondering if this code will work

? "App Check"
;Run VB Script to do something
if WDAYNO = 3
run 'cscript \\server\netlogon\XXX.vbs'
else
Endif

I have this new vbs that I want to convert to KiX... any advice where to start ?

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

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

Dim strValue
strValue = ""
'Determine most recent installed version of Java
strKeyPath = "SOFTWARE\Microsoft\Internet Explorer\AdvancedOptions\JAVA_SUN\SELECT"
strValueName = "RegPath"
oReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
'Wscript.Echo strValue 'something like Software\JavaSoft\Java Plug-in\1.6.0_02

'Set values for most recent version
If strValue <> "" Then
strKeyPath = strValue
strValueName = "UseJava2IExplorer"
dwValue = 0
oReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue
End If

'Set values for java versions on the standard desktop image
'Version 1.3.1_15
strKeyPath = "SOFTWARE\JavaSoft\Java Plug-in\1.3.1_15"
strValueName = "UseJava2IExplorer"
dwValue = 0
oReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue

'Version 1.4.2_07
strKeyPath = "SOFTWARE\JavaSoft\Java Plug-in\1.4.2_07"
strValueName = "UseJava2IExplorer"
dwValue = 0
oReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue
strValueName = "HideSystemTrayIcon"
dwValue = 1
oReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue

'Version 1.5.0_01
strKeyPath = "SOFTWARE\JavaSoft\Java Plug-in\1.5.0_01"
strValueName = "UseJava2IExplorer"
dwValue = 0
oReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue
strValueName = "HideSystemTrayIcon"
dwValue = 1
oReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue

'Disable Java Automatic Updates
strKeyPath = "SOFTWARE\JavaSoft\Java Update\Policy"
strValueName = "EnableJavaUpdate"
dwValue = 0
oReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue
strValueName = "EnableAutoUpdateCheck"
oReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue




BillBarnard
(Starting to like KiXtart)
2007-08-10 03:38 PM
Re: Specify a day of week to run

The macro @day will return the day of the week.

If @day="Tuesday"

Shell "cscript YourVBS.vbs"

Endif

Then use either Shell or Run to run your vb script with cscript

Bill


NTDOCAdministrator
(KiX Master)
2007-08-10 07:21 PM
Re: Specify a day of week to run

Why not just convert the VBS script to KiXtart and then you won't have to manage 2 different types of scripts.

99% of all VB Scripts can be easily converted. There are a few exceptions that can not but rarely do you see them in use for normal scripts.


John45
(Fresh Scripter)
2007-08-13 08:01 PM
Re: Specify a day of week to run

Im ashamed to admit i didnt know you could convert it.

I have no previous experience with KiX or VBS, but with all the changes around my company im getting new tasks left and right.

Ill dig around and see what else I can find.


NTDOCAdministrator
(KiX Master)
2007-08-13 10:52 PM
Re: Specify a day of week to run

Well can't promise but if you post the VB Script code here (using the CODE TAGS) I'm sure someone can help convert it for you.

John45
(Fresh Scripter)
2007-08-14 03:10 PM
Re: Specify a day of week to run

 Code:
Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

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

Dim strValue
strValue = ""
'Determine most recent installed version of Java
strKeyPath = "SOFTWARE\Microsoft\Internet Explorer\AdvancedOptions\JAVA_SUN\SELECT"
strValueName = "RegPath"
oReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
'Wscript.Echo strValue 'something like Software\JavaSoft\Java Plug-in\1.6.0_02

'Set values for most recent version
If strValue <> "" Then
strKeyPath = strValue
strValueName = "UseJava2IExplorer"
dwValue = 0
oReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue
End If

'Set values for java versions on the standard desktop image
'Version 1.3.1_15
strKeyPath = "SOFTWARE\JavaSoft\Java Plug-in\1.3.1_15"
strValueName = "UseJava2IExplorer"
dwValue = 0
oReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue

'Version 1.4.2_07
strKeyPath = "SOFTWARE\JavaSoft\Java Plug-in\1.4.2_07"
strValueName = "UseJava2IExplorer"
dwValue = 0
oReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue
strValueName = "HideSystemTrayIcon"
dwValue = 1
oReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue

'Version 1.5.0_01
strKeyPath = "SOFTWARE\JavaSoft\Java Plug-in\1.5.0_01"
strValueName = "UseJava2IExplorer"
dwValue = 0
oReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue
strValueName = "HideSystemTrayIcon"
dwValue = 1
oReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue

'Disable Java Automatic Updates
strKeyPath = "SOFTWARE\JavaSoft\Java Update\Policy"
strValueName = "EnableJavaUpdate"
dwValue = 0
oReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue
strValueName = "EnableAutoUpdateCheck"
oReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue


any suggestions?


Gargoyle
(MM club member)
2007-08-14 09:45 PM
Re: Specify a day of week to run

ReadValue() and WriteValue() are your friends here.

Just do a read when collecting the information and write when you want to set or change it.