Splunker
asked on
I need help to tell me what end statement I need to keep this routine from erroring out.
I got this script to run another script from login. I tried testing it and it came back with an error when the person logged in. The errors was something like missing an end statement. I dont know VB. I pasted only whats below into a text file and then changed the ext to .vbs and put it into my login script. I do have another vb script names RunasSample.vbs which I assume this statement is trying to execute it. Do I need a "end" at the end of this script or something like "wscript.quit" Keep in mind I did fill in the server name, sharename and directories to where the other vb script is located.
or is this statement needing alot more coding?
Thanks
Jeff
'************************* ********** ********** ********** ********** ****
' Sample statements to call from the login script
Dim g_OShell
Set g_OShell = CreateObject ("Wscript.Shell")
g_OShell.Run WScript.FullName & " \\ServerName\ShareName\Dir ectory1\Di rectory2\R unAsSample .vbs", 0, False
or is this statement needing alot more coding?
Thanks
Jeff
'*************************
' Sample statements to call from the login script
Dim g_OShell
Set g_OShell = CreateObject ("Wscript.Shell")
g_OShell.Run WScript.FullName & " \\ServerName\ShareName\Dir
The error you are talkign about can't come from this script. It must be coming from RunAsSample.vbs Post that.
ASKER
Okay here it is below
**************************
Option Explicit
On Error Resume Next
Dim WshShell
Dim WshNetwork
Dim WshEnv
Dim fso
Dim WinPath
Dim RunAsFlag
Dim sUser
Dim sPass
Dim ProgramName
Dim Command
Dim CommandFile
Const ForReading = 1, ForWriting = 2, ForAppend = 8
Set WshShell = CreateObject("WScript.Shel
Set WshEnv = WshShell.Environment("Proc
Set fso = CreateObject("Scripting.Fi
Set WshNetwork = WScript.CreateObject("WScr
WinPath = WshEnv("SystemRoot")&"\Sys
RunAsFlag = True
If Not fso.FileExists(WinPath) Then
Set CommandFile = fso.OpenTextFile ("C:\" & WshNetwork.ComputerName & ".Command.txt", ForAppend, True)
CommandFile.WriteLine Now() & ": Can't find or verify " & WinPath & "." & VBCRLF & "You must be running Windows 2000 or higher for this script to work."
CommandFile.Close
RunAsFlag = False
End If
'*************************
' This is the user name and password of the account that is the local administrator of the workstation
sUser = "domain\username"
sPass = "password" & VBCrLf
' Enter the location of the file to be installed. Must be a UNC location as drive
' letters will not work. Multiple ProcessFile lines may be included.
ProcessFile "\\servername\directory\di
ProcessFile "\\servername\directory\di
'*************************
EndScript
'*************************
Sub ProcessFile (ProgramName)
On Error Resume Next
Dim Return
Dim InstallLogName
Dim A
Dim ProgramLocation
Dim CurrentVersion
Err.Clear
If Not fso.FileExists(ProgramName
Set CommandFile = fso.OpenTextFile ("C:\" & WshNetwork.ComputerName & ".Command.txt", ForAppend, True)
CommandFile.WriteLine Now() & ProgramName & " does not exist"
CommandFile.Close
Exit Sub
End If
InstallLogName = UCase(ProgramName) & ".LOG"
A = InStrRev(InstallLogName, "\")
If A > 0 Then
InstallLogName = Right(InstallLogName, Len(InstallLogName) - A)
End If
InstallLogName = "C:\" & WshNetwork.ComputerName & "." & Trim(InstallLogName)
fso.DeleteFile InstallLogName, True
Err.Clear
Set CommandFile = fso.OpenTextFile ("C:\" & WshNetwork.ComputerName & ".Command.txt", ForAppend, True)
If RunAsFlag = True Then
Command = "CMD /c runas.exe /noprofile /user:" & sUser & " " & Chr(34) & ProgramName & " /s /v/qn\" & Chr(34) & " /l*v \" & Chr(34) & InstallLogName & "\" & Chr(34) & Chr(34) & Chr(34)
Else
Command = Chr(34) & ProgramName & Chr(34) & " /s /v/qn" & Chr(34) & " /l*v \" & Chr(34) & InstallLogName & Chr(34) & Chr(34)
End If
CommandFile.WriteLine Now() & ": " & Command
CommandFile.Close
return = WshShell.Run (Command, 1, False)
If RunAsFlag = True Then
WScript.Sleep 30 'need to give time for window to open.
WshShell.AppActivate (WinPath) 'make sure we grab the right window to send password to
WshShell.SendKeys sPass 'send the password to the waiting window.
End If
WScript.Sleep 30000
End Sub
Sub EndScript
Set WshShell = Nothing
Set WshEnv = Nothing
Set fso = Nothing
Set WshNetwork = Nothing
WScript.Quit
End Sub
ASKER
It also has this stuff below at the very top.
************************** ****
'<% RunAsSample.VBS
'
' ************************** ********** ********** ********** ********** ********** *****
' * THIS PROGRAM IS OFFERED AS IS AND MAY BE FREELY MODIFIED OR ALTERED AS *
' * NECESSARY TO MEET YOUR NEEDS. THE AUTHOR MAKES NO GUARANTEES OR WARRANTIES, *
' * EXPRESS, IMPLIED OR OF ANY OTHER KIND TO THIS CODE OR ANY USER MODIFICATIONS. *
' * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED IN A SECURED LAB *
' * ENVIRONMENT. USE AT YOUR OWN RISK. *
' ************************** ********** ********** ********** ********** ********** *****
'************************* ********** ********** ********** ********** ********** ********** ********** *******
'* Sample statements to call from the login script *
'* *
'* Dim g_OShell *
'* Set g_OShell = CreateObject ("Wscript.Shell") *
'* g_OShell.Run WScript.FullName & " \\ServerName\ShareName\Dir ectory1\Di rectory2\R unAsSample .vbs", 0, False *
'************************* ********** ********** ********** ********** ********** ********** ********** *******
**************************
'<% RunAsSample.VBS
'
' **************************
' * THIS PROGRAM IS OFFERED AS IS AND MAY BE FREELY MODIFIED OR ALTERED AS *
' * NECESSARY TO MEET YOUR NEEDS. THE AUTHOR MAKES NO GUARANTEES OR WARRANTIES, *
' * EXPRESS, IMPLIED OR OF ANY OTHER KIND TO THIS CODE OR ANY USER MODIFICATIONS. *
' * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED IN A SECURED LAB *
' * ENVIRONMENT. USE AT YOUR OWN RISK. *
' **************************
'*************************
'* Sample statements to call from the login script *
'* *
'* Dim g_OShell *
'* Set g_OShell = CreateObject ("Wscript.Shell") *
'* g_OShell.Run WScript.FullName & " \\ServerName\ShareName\Dir
'*************************
That also seems ok. Could you run that script directly? Like
C:\WINNT\system32\cscript. exe \\ServerName\ShareName\Dir ectory1\Di rectory2\R unAsSample .vbs
C:\WINNT\system32\cscript.
ASKER
Maybe I should give you the exact error first.. Maybe I am missing something. I will be right back with the exact error.
ASKER
Below is the error. RunAsITI.vbs is what I name the code for the
"Sample statement to call from Login script" The first code I posted this is why I thought it was an end statment issue.
**************************
Windows Script Host
Script: \user\scripts\logon\RunAsI
Line: 1
Char: 36
Error: Expected end of statement
code: 800A0401
Source: Microsoft compilation error.
How are you running this script?
ASKER
I do it using a group policy for the logon. I want this program to install when users login. This script was created by our vendor for software we use that needs to be upgraded on every workstation. This script is suppose eliminate us having to go to each workstation to install it. It logs in with administrative user and permissions and installs it for the user.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
To be more exact. I right click on the OU that my user is in and go to properties select the group policy tab. Select new policy name it Premier upgrade. Edit the policy go to the user configuration in the Windows settings then scripts then logon. Open the logon select show files put the RunAsITI.vbs in there. Then I select Add for the Logon and pick the RunAs ITI.vbs. then close out of it all. I have the user login and then I get this error.
ASKER
Okay I found out what wrong. On The RunAsITI.vbs there was a one astrik in the code that I didnt see. It was way off on right side of the page I didnt see it because would have had to scroll over. when I pasted it into the post I deleted it and didnt realize it.