Jump to content

two part question


gcue
 Share

Recommended Posts

here's what im trying to do:

i run a program that takes a screenshot on a remote machine (sc.exe) using psexec.exe

sc.exe prompts the user if they will authorize a screenshot or not.

if they select yes, a screenshot is taken

if they select no, a flag is written (noss.flg)

i run a check 5 seconds later to see if a screenshot exists if a screenshot does not exist i report an error "unable to take screenshot bc ..."

i also run a check to see if noss.flg exists, if it does i tell the script user that the user on remote machine denied permission

here are my problems:

1. if the user doesnt respond in 5 seconds, i get errored out that a screenshot couldnt be taken

2. when the user answers no, i get both errors (user denied permission AND screenshots do not exist)

help!

Func Open()

If FileExists ("\\" & GUICtrlRead($asset) & "\c$\temp\sc.exe") Then
  FileDelete ( "\\" & GUICtrlRead($asset) & "\c$\temp\sc.exe")
EndIf

FileCopy ( "sc.exe", "\\" & GUICtrlRead($asset) & "\c$\temp", 1)

RunWait(@ScriptDir & "\psexec.exe " & "\\" & GUICtrlRead($asset) & " -d -i c:\temp\sc.exe" )

Sleep(5000)

If FileExists ("\\" & GUICtrlRead($asset) & "\c$\temp\noss.flg") Then
   MsgBox(16, "Remote Screenshot", 'Permission for screenshot denied by ' & GUICtrlRead($asset))
   Call("Cleanup")
EndIf

If FileExists ( "\\" & GUICtrlRead($asset) & "\c$\temp\" & "*" & GUICtrlRead($asset) & "*.jpg") Then
  FileMove("\\" & GUICtrlRead($asset) & "\c$\temp\" & "*" & GUICtrlRead($asset) & "*.jpg", @ScriptDir & "\Screenshots\")
  Run(@WindowsDir & "\explorer.exe " & @ScriptDir & "\Screenshots")
Else
  MsgBox(16, "Remote Screenshot", 'Unable to take a screenshot from ' & GUICtrlRead($asset) &@CRLF & _
                                  ''&@CRLF & _
                                  'Probable KNOWN reasons:'&@CRLF & _
                                  ''&@CRLF & _
                                  '1.  Asset is on CAD screen.'&@CRLF & _
                                  '2.  Bloomberg is the active window.')
EndIf
  Call("Cleanup")
EndFunc


Func Cleanup()
If FileExists ("\\" & GUICtrlRead($asset) & "\c$\temp\sc.exe") Then
   FileDelete ( "\\" & GUICtrlRead($asset) & "\c$\temp\sc.exe")
EndIf

If FileExists ("\\" & GUICtrlRead($asset) & "\c$\temp\noss.flg") Then
   FileDelete ("\\" & GUICtrlRead($asset) & "\c$\temp\noss.flg")
EndIf
EndFunc
Link to comment
Share on other sites

here are my problems:

1. if the user doesnt respond in 5 seconds, i get errored out that a screenshot couldnt be taken

2. when the user answers no, i get both errors (user denied permission AND screenshots do not exist)

Try to solve the 1st issue by creating some "please-wait.txt" and poll for this one, until it's gone through some action you will have to execute on the remote PC after the auth popup was answered.

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

how would i do that?

Try to solve the 1st issue by creating some "please-wait.txt" and poll for this one, until it's gone through some action you will have to execute on the remote PC after the auth popup was answered.

Regards, Rudi.

Link to comment
Share on other sites

can someone please help with this?

id be so thankful!

here's what im trying to do:

i run a program that takes a screenshot on a remote machine (sc.exe) using psexec.exe

sc.exe prompts the user if they will authorize a screenshot or not.

if they select yes, a screenshot is taken

if they select no, a flag is written (noss.flg)

i run a check 5 seconds later to see if a screenshot exists if a screenshot does not exist i report an error "unable to take screenshot bc ..."

i also run a check to see if noss.flg exists, if it does i tell the script user that the user on remote machine denied permission

here are my problems:

1. if the user doesnt respond in 5 seconds, i get errored out that a screenshot couldnt be taken

2. when the user answers no, i get both errors (user denied permission AND screenshots do not exist)

help!

Func Open()

If FileExists ("\\" & GUICtrlRead($asset) & "\c$\temp\sc.exe") Then
  FileDelete ( "\\" & GUICtrlRead($asset) & "\c$\temp\sc.exe")
EndIf

FileCopy ( "sc.exe", "\\" & GUICtrlRead($asset) & "\c$\temp", 1)

RunWait(@ScriptDir & "\psexec.exe " & "\\" & GUICtrlRead($asset) & " -d -i c:\temp\sc.exe" )

Sleep(5000)

If FileExists ("\\" & GUICtrlRead($asset) & "\c$\temp\noss.flg") Then
   MsgBox(16, "Remote Screenshot", 'Permission for screenshot denied by ' & GUICtrlRead($asset))
   Call("Cleanup")
EndIf

If FileExists ( "\\" & GUICtrlRead($asset) & "\c$\temp\" & "*" & GUICtrlRead($asset) & "*.jpg") Then
  FileMove("\\" & GUICtrlRead($asset) & "\c$\temp\" & "*" & GUICtrlRead($asset) & "*.jpg", @ScriptDir & "\Screenshots\")
  Run(@WindowsDir & "\explorer.exe " & @ScriptDir & "\Screenshots")
Else
  MsgBox(16, "Remote Screenshot", 'Unable to take a screenshot from ' & GUICtrlRead($asset) &@CRLF & _
                                  ''&@CRLF & _
                                  'Probable KNOWN reasons:'&@CRLF & _
                                  ''&@CRLF & _
                                  '1.  Asset is on CAD screen.'&@CRLF & _
                                  '2.  Bloomberg is the active window.')
EndIf
  Call("Cleanup")
EndFunc


Func Cleanup()
If FileExists ("\\" & GUICtrlRead($asset) & "\c$\temp\sc.exe") Then
   FileDelete ( "\\" & GUICtrlRead($asset) & "\c$\temp\sc.exe")
EndIf

If FileExists ("\\" & GUICtrlRead($asset) & "\c$\temp\noss.flg") Then
   FileDelete ("\\" & GUICtrlRead($asset) & "\c$\temp\noss.flg")
EndIf
EndFunc
Link to comment
Share on other sites

Hi.

[create a "flag" file on the remote PC and poll for it]

how would i do that?

1.) from a script running on the remote PC. Then trigger your script on the remote PC.

2.) using pstools from the local PC to the remote one. Then let the program on the remote PC delete that flag file at it's end.

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...