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: https://www.abyssmedia.com/forum/posting ... ,f,15.html, http://go.microsoft.com/fwlink?LinkID=45840.
But since I can run it with cscript and wscript, I don't see where a security issue exists. I have to assume it is the compiled exe.
Scripcryptor flashes briefly and fails to run script
-
- Posts: 3
- Joined: Mon Feb 09, 2009 7:47 pm
-
- Site Admin
- Posts: 476
- Joined: Fri Feb 13, 2004 1:05 pm
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: http://support.microsoft.com/kb/896358
Your event log points to the problem with HTML Help. You may find solution here: http://support.microsoft.com/kb/896358
-
- Posts: 3
- Joined: Mon Feb 09, 2009 7:47 pm
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
WScript.Quit
End If
Set objFSO = CreateObject("Scripting.FileSystemObject")
' delete our local copy of the file if it exists
If (objfso.FileExists("c:\whoisloggedon.txt")) Then
objfso.DeleteFile("c:\whoisloggedon.txt")
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("=====================================================================")
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")
Else
For Each objSession in colSessions
If objSession.LogonType = 2 Then
objTextFileo.WriteLine( "Logon type: Console")
Else
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)
Next
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(" ")
objTextFileo.WriteLine("=====================================================================")
ctr = ctr + 1
Next
objTextFileo.WriteLine(" ")
objTextFileo.WriteLine( "Total users logged on: " & ctr)
objTextFileo.WriteLine("=====================================================================")
End If
objTextFileo.Close
' now use Notepad to display the local output copy of the file
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "notepad c:\whoisloggedon.txt"
' 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
WScript.Quit
End If
Set objFSO = CreateObject("Scripting.FileSystemObject")
' delete our local copy of the file if it exists
If (objfso.FileExists("c:\whoisloggedon.txt")) Then
objfso.DeleteFile("c:\whoisloggedon.txt")
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("=====================================================================")
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")
Else
For Each objSession in colSessions
If objSession.LogonType = 2 Then
objTextFileo.WriteLine( "Logon type: Console")
Else
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)
Next
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(" ")
objTextFileo.WriteLine("=====================================================================")
ctr = ctr + 1
Next
objTextFileo.WriteLine(" ")
objTextFileo.WriteLine( "Total users logged on: " & ctr)
objTextFileo.WriteLine("=====================================================================")
End If
objTextFileo.Close
' now use Notepad to display the local output copy of the file
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "notepad c:\whoisloggedon.txt"