You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.1 KiB
Plaintext

Option Explicit
Dim wshshell,fso,Args
Dim Key,strPassword, strUser,Fnct,strTemp,strNewKey
Const WinlogonKey = _
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
Set Args = wscript.Arguments
strUser = Args(0)
strPassword = Args(1)
Set wshshell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set Fnct = CreateObject("Install.Functions")
Key = WinlogonKey & "\AutoAdminLogon"
wshshell.RegWrite Key, 1
Key = WinlogonKey & "\DefaultUserName"
if wshshell.RegRead(Key) = "Autologon" Then
wshshell.RegWrite (WinlogonKey & "\DefaultPasswordAutologon"), _
wshshell.RegRead(WinlogonKey & "\DefaultPassword")
End If
wshshell.RegWrite Key, strUser
Key = WinlogonKey & "\DefaultPassword"
wshshell.RegWrite Key, strPassword
key = "HKEY_LOCAL_MACHINE\SOFTWARE\Beckhoff\TWinCAT\System\PlcCtrlPath"
strTemp = wshshell.RegRead(Key)
strNewKey = Key & "org"
wshshell.RegWrite strNewKey,strTemp
wshshell.RegWrite key,GetTwinCATFolder() & "\Plc\TCatPlcCtrl.exe"
key = "HKEY_LOCAL_MACHINE\SOFTWARE\Beckhoff\TWinCAT\System\SysManagerPath"
strTemp = wshshell.RegRead(Key)
strNewKey = Key & "org"
wshshell.RegWrite strNewKey,strTemp
wshshell.RegWrite key,GetTwinCATFolder() & "\Io\TCatSysManager.exe"
Call Fnct.ExitWindows(2)
Function GetTWinCATFolder
Dim l_strDir
l_strDir = wshshell.ExpandEnvironmentStrings("%TWINCATDIR%")
If l_strDir = "%TWINCATDIR%" Then l_strDir = "C:\TWinCAT"
GetTWinCATFolder = l_strDir
End Function
Function GetProgramFiles
Dim l_strDir
l_strDir = wshshell.ExpandEnvironmentStrings("%PROGRAMFILES%")
If l_strDir = "%PROGRAMFILES%" Then l_strDir = "C:\Program Files"
GetProgramFiles = l_strDir
End Function
Function GetCurrentPath()
Dim l_strScriptName
Dim l_strTemp
l_strScriptName = WScript.ScriptFullName
l_strTemp = WScript.ScriptName
GetCurrentPath = Left(l_strScriptName, Len(l_strScriptName) - Len(l_strTemp))
End Function
Function KeyExists(p_strKey)
Dim l_strTemp
On Error Resume Next
Err.Clear
l_strTemp = wshshell.RegRead(p_strKey)
If Err.Number <> 0 Then
KeyExists = False
Else
KeyExists = True
End If
On Error Goto 0
End Function