Page 1 of 1

Scripcryptor flashes briefly and fails to run script

Posted: Mon Feb 09, 2009 7:54 pm
by msacademy
I am running a script that works fine in cscript and wscript. Is uses a:

strComputer = InputBox("What Is The Server Name To Query For Users?", "Windows Who Command")
If strcomputer = "" Or strcomputer = " " Then wscript.quit

to prompt for a value. But I briefly see a command box (but cannot read it) and the exe ends. But the prompt comes up fine in both script processors. Any ideas?

I do see this in the event log:

The description for Event ID ( 1904 ) in Source ( HHCTRL ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: ... ,f,15.html,

But since I can run it with cscript and wscript, I don't see where a security issues exists. I have to assume it is the compiled exe.

Posted: Mon Feb 09, 2009 9:18 pm
by support
What version of ScriptCryptor you have? Latest from this site work just find with you sample code.

Your event log points to the problem with HTML Help. You may find solution here:

Posted: Mon Feb 09, 2009 9:27 pm
by msacademy
I am using the latest code because I just got the link from AbyssMedia today. Here is the complete script: (domain\administrator is the domain admin so that I can see computer info I am not authorized to with my individual user ID). Again, it works fine with cscript and wscript.

' Randy Schmidt
' January 2009
' this script will query any server for users logged on and display results in Notepad
Set WshShell = CreateObject("WScript.Shell")
' force cscript to run this even if launched from wscript so that logging will show

If InStr(1, WScript.FullName, "CScript", vbTextCompare) = 0 Then
WshShell.Run "cscript """ & WScript.ScriptFullName & """", 1, False
End If

Set objFSO = CreateObject("Scripting.FileSystemObject")
' delete our local copy of the file if it exists

If (objfso.FileExists("c:\whoisloggedon.txt")) Then
End If

' this is our output file which is nothing more than a copy of the input file but avoids locking the original file so it can updated by external processes
Const ForAppending = 8
Set objTextFileo = objFSO.OpenTextFile _
("c:\whoisloggedon.txt", ForAppending, True)

strComputer = InputBox("What Is The Server Name To Query For Users?", "Windows Who Command")
If strcomputer = "" Or strcomputer = " " Then wscript.quit

objTextFileo.WriteLine( "Here is Who Is Logged On To " & strComputer)
objTextFileo.WriteLine(" ")
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServices = objSWbemLocator.ConnectServer (strComputer, _
"root\cimv2", "domain\administrator", "secret")

Set colSessions = objSWbemServices.ExecQuery("Select * from Win32_LogonSession Where LogonType = 2 OR LogonType = 10")

If colSessions.Count = 0 Then
objTextFileo.WriteLine("No interactive users found")


For Each objSession in colSessions

If objSession.LogonType = 2 Then
objTextFileo.WriteLine( "Logon type: Console")
objTextFileo.WriteLine( "Logon type: RDP/Terminal Server")
End If

Set colList = objSWbemServices.ExecQuery("Associators of " _
& "{Win32_LogonSession.LogonId=" & objSession.LogonId & "} " _
& "Where AssocClass=Win32_LoggedOnUser Role=Dependent" )

For Each objItem in colList
objTextFileo.WriteLine( "User: " & objItem.Name)
objTextFileo.WriteLine( "FullName: " & objItem.FullName)
objTextFileo.WriteLine( "Domain: " & objItem.Domain)


sessyear = Left(objsession.starttime,4)
sessmonth = Mid(objsession.starttime,5,2)
sessday = Mid(objsession.starttime,7,2)
sesshour = Mid(objsession.starttime,9,2)
sessmin = Mid(objsession.starttime,11,2)
sesssec = Mid(objsession.starttime,13,2)
sessionstart = sesshour & ":" & sessmin & ":" & sesssec & " on " & sessmonth & "/" & sessday & "/" & sessyear

objTextFileo.WriteLine( "Session start time: " & sessionstart)
objTextFileo.WriteLine(" ")
ctr = ctr + 1

objTextFileo.WriteLine(" ")
objTextFileo.WriteLine( "Total users logged on: " & ctr)

End If


' now use Notepad to display the local output copy of the file
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "notepad c:\whoisloggedon.txt"

Posted: Tue Feb 10, 2009 9:48 pm
by support
Problem solved via email.