Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logon script

Status
Not open for further replies.
Mar 18, 2002
12
US
Having a bit of a problem. We have written a custom application that is to launch at logon in an NT4 domain with NT4 wkst and W2k Pro clients. We have put the application and its related files in a folder and have the logon.bat file point to the .VBS script as follows:

@echo off
cscript infocon.vbs

INFOCON.VBS is as below:
Option Explicit

Dim objFSO, objWS
Dim WshShell, WshNetwork
Dim letter, strTest, Return

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set WshShell = WScript.CreateObject("WScript.Shell")

'Map network drive to run INFOCON.EXE
driveAvailable
objWS.Echo "Available drive found..."
WshNetwork.MapNetworkDrive +Chr(letter)+":", "\\ourdhcp01\d$\temp"

' Execute INFOCON.EXE
Return = WshShell.Run(Chr(letter) &":\infocon.exe", 1, True)

' Disconnect mapped drive
driveDisconnect

'***********************************************************
' Map drive to hotfixes using next available drive letter
Sub driveAvailable
letter=Asc("h")
While objFSO.DriveExists(Chr(letter)+":")
letter=letter+1
Wend
End Sub

' Disconnect drive mapped by driveAvailable
Sub driveDisconnect
WShNetwork.RemoveNetworkDrive +Chr(letter)+":"
End Sub

Whenever this runs, the drive is mapped, the script starts, then returns run-time error 75 path can not be found. Any suggestions? Also, is there a way to keep the command prompt window from displaying? We do not want users to be able to stop the script before it has completed.

Thanks,
David Moore
 
Oops, one more bit, the INFOCON.EXE program looks for an .RTF file in order to run. If I execute the script from within Windows Explorer, it run fine. When I log out and log back in, it gets the error message.

David
 
This may not be the answer but I have had a similar problem when the drive does not map in time, try putting in a Wscript.Sleep to make it wait for a short while.

Or do loop to check to see if the drive is there, when it appears run your command

Steve
 
Hi There,

If you do not want the users to be able to stop the script change it from a cscript to a wscript. It should run in the background.
 
Thanks for the input, but it's still not working. It appears that it has to do with the INFOCON.EXE application. It does not appear to find the .RTF file in the same directory. Is there anyway to set a working directory or something so that it will look in the same directory as the executable?

Thanks again for the help.

David
 
Can you not run Infocon with the name of the RTF file on the end

Return = WshShell.Run(Chr(letter) &":\infocon.exe " & Chr(letter) &":\rtfile.rtf", 1, True)


Regards
Steve
 
Well, I tried that but still no luck. Maybe I should go back into the application and recode it to accept the path to the .RTF file as an argument and maybe that will work.

David
 
What is throwing up the Error 75 - Infocon or the VBscript

Try taking out the Drive disconnect, rem it or something. sorry but have also run into a problem where although I specify True for the program to wait for completion on the WSH.RUN it does not always wait, I'm guessing it looses the thread or something.

If it was to start the program then disconnect the drive, then the RTF would not exist.

Worth a try

Steve
Regards
Steve Friday
 
INFOCON is throwing the error. It is looking for the .RTF file but isn't getting it. My guess is it is looking in a different directory, only a thought. With a little help from a co-worker, I have gone into INFOCON and changed

Private Sub Form_Load()

AlwaysOnTop(Form2) = True

RichTextBox1.LoadFile "infocon.rtf"

End Sub

to

Private Sub Form_Load()

AlwaysOnTop(Form2) = True
' System variable Command contains all parameters
cmdline = Command
' Check for presence of path info
If InStr(cmdline, "\") > 0 Or InStr(cmdline, "/") > 0 Then
RichTextBox1.LoadFile cmdline
Else
RichTextBox1.LoadFile "infocon.rtf"
End If

End Sub


Now from the command line I can specifiy the path to the .RTF. I have tried it with my logon script and seems to work okay. Thanks for all the help.

David
 
Out of curiousity, what is the VBScript equivalent to the DOS command %0\..\infocon.exe?

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top