Radimus
(KiX Supporter)
2002-11-14 09:22 PM
new project...

how to remotely push an input box and return the entered value...

ShawnAdministrator
(KiX Supporter)
2002-11-14 09:33 PM
Re: new project...

you mean something like NET SEND, in reverse:

c:\> NET PROMPT \\REMOTE "Who is this?"

tricky ...


Radimus
(KiX Supporter)
2002-11-14 09:35 PM
Re: new project...

Yep, that is what I would like...

LonkeroAdministrator
(KiX Master Guru)
2002-11-14 09:39 PM
Re: new project...

it's easy when the script does the inputbox script in the other machine which stores the data into the system where is the main script...

but, to do it with one script without separate remote processes...


Radimus
(KiX Supporter)
2002-11-14 09:45 PM
Re: new project...

personally, I expect to have to do something like:

push a script to the remote pc
remote exec it
user enters the data
remote script saves it to file

orig script does findproc() until remote script exits, then reads the remote file
clean up of temp files.

kind of cumbersome... Looking for a better way


Chris S.
(MM club member)
2002-11-14 10:45 PM
Re: new project...

I did this during a little experiment when I was trying to do a remote copy on a WMI-enable Win 95 box.

I copied this script to my target PC...
code:
break on
;setconsole("Hide")

If $SRC <> "" and $DST <> ""
$MSG=GUICopy("Copy", "$SRC", "$DST", 1552)
$nul = SENDMESSAGE($REQUESTOR,$MSG)
Else
$nul = SENDMESSAGE($REQUESTOR, "Please specify a source and destination")
EndIf

function GUICopy($CMD, $Source, $Destination, OPTIONAL $Flags)
If not $Flags $Flags=0 Endif
If not exist($Source) $GUICopy = "Source does not exist." Exit (2) Endif
If not exist($Destination) $GUICopy = "Destination does not exist." Exit (3) Endif
If @INWIN=1 $VER=GETFILEVERSION(%WINDIR%+"\System32\Shell32.dll","FileVersion")
Else $VER=GETFILEVERSION("%WINDIR%\System\Shell32.dll","FileVersion") Endif
If $VER<"4.71" $GUICopy = "Cannot create namespace. Incorrect Shell32.dll version." Exit (4) Endif
$objShell=CreateObject("Shell.Application")
$objFolder=$objShell.NameSpace($Destination)
Select
Case $CMD="Copy" $objFolder.CopyHere($Source, $Flags)
Case $CMD="Move" $objFolder.MoveHere($Source, $Flags)
Case 1 $GUICopy = "GUICopy Syntax Incorrect. Use COPY or MOVE." $objShell=0 Exit (5)
EndSelect
$objShell=0
If @error = 0 $GUICopy = "$CMD Successful" else $GUICopy = "$CMD Failed" Endif
Exit @error
endfunction

And this ran it remotely using this script (please forgive the sloppiness of this code, as I have not finished it)...
code:
Break On

$RemoteBox = "TestPC"
$ServerShr = "\\Server\share"
$ID = "Domain\UserID" ; Use any account with local admin rights
$PW = "XXXXXXX" ; Obvious security concerns
$SRC = "\\Server\Share\Adobe.exe"
$DST = "c:\windows\temp"

$CCommand = 'kix32.exe c:\remote_copy.kix $$src="$src" $$dst="$dst" $$requestor="@wksta"'
$RCommand = "c:\windows\temp\adobe.exe"

$Connect = CreateObject("WbemScripting.SWbemLocator")
If @ERROR @serror ? EndIf
$Con2 = $Connect.ConnectServer("$remotebox","root\cimv2","$ID","$PW")
If @ERROR @serror ? EndIf
$Con2.Security_.ImpersonationLevel = 3
If @ERROR @serror ? EndIf
$Con3 = $Con2.Get("Win32_Process")
If @ERROR @serror ? EndIf
$Map = $Con3.Create($CCommand)
If @ERROR @serror ? EndIf
;sleep 10
$Con4 = $Con2.Get("Win32_Process")
If @ERROR @serror ? EndIf
;sleep 5
$Process = $Con4.Create($RCommand)
If @ERROR @serror ? EndIf

If NOT $Process
? "Process executed successfully!"
Else
? "Process failed..."
EndIf

$Connect=""
$Process=""
$Con2=""
$Con3=""



Will Hetrick
(Hey THIS is FUN)
2002-11-19 01:38 PM
Re: new project...

Rad,
What about pushing the script to the user with the dialog box then after you get the answer, net send the answer back to you.
code:
 
$X = MessageBox("Are you Ok","Felling alright",1,1)
Shell "net send radimus $x"





Radimus
(KiX Supporter)
2002-11-19 01:42 PM
Re: new project...

That wouldn't work if I sent the code out to 50 PCs at a time...

Kdyer
(KiX Supporter)
2002-11-19 01:56 PM
Re: new project...

Rad,

Using the example of -

echo y | del .

Can't you do the same thing?

echo @userid | NET PROMPT \\REMOTE "Who is this?"

Kent


Will Hetrick
(Hey THIS is FUN)
2002-11-19 02:06 PM
Re: new project...

What about sending the answer to a remote registy.
Where $computer 2 is your machine
code:
  
Function CHECKREG($VALUE,$WHERE)
$REG = ReadValue ($Computer2 + "\HKEY_LOCAL_MACHINE\SOFTWARE\CWOPA\MACHINE", "$WHERE")
If $value = " " OR Len($Value) = 0
$Checkreg = $reg
Else
If NOT KeyExist($Computer2 + "\HKEY_LOCAL_MACHINE\SOFTWARE\CWOPA\MACHINE")
$ReturnCode = AddKey($Computer2 + "\HKEY_LOCAL_MACHINE\SOFTWARE\CWOPA\MACHINE")
EndIf
$X = WriteValue ($Computer2 + "\HKEY_LOCAL_MACHINE\SOFTWARE\CWOPA\MACHINE", "$WHERE","$value","REG_SZ")
$CHECKREG = $VALUE
EndIf

Return
EndFunction



ShawnAdministrator
(KiX Supporter)
2002-11-19 02:09 PM
Re: new project...

Rad,

Is WMI an option here ? Trying to think of a way to do it without having to install some kind of agent on the wkstn ...


Radimus
(KiX Supporter)
2002-11-19 02:17 PM
Re: new project...

all clients are win2k, so WMI is fine...

for the client to write to the registry on my PC, they would need admin (or equiv) on my box... not likely [Big Grin]

I'd think that writeprofilestring to a common/networked ini file would be easiest

[ 19. November 2002, 14:20: Message edited by: Radimus ]


Will Hetrick
(Hey THIS is FUN)
2002-11-19 02:23 PM
Re: new project...

This is what i use from your WMi query to the ini file.

code:
  
; Writes information to the an INI file
; Example: $Comp = CHECKREG($COMP,"MANUFACTURER")
Function CHECKINI($VALUE,$WHERE)
$ini = ReadProfileString($inifile,@wksta,"$where")
If $ini = " " OR Len($ini) = 0
$ini = "N/A"
EndIf
If $Value = " " OR Len($Value) = 0
$Checkini = $ini
$X = WriteProfileString($Inifile,@wksta,"$WHERE","$Checkini")
Else
$CHECKini = $VALUE
$X = WriteProfileString($Inifile,@wksta,"$WHERE","$Checkini")
EndIf
Return
EndFunction



ShawnAdministrator
(KiX Supporter)
2002-11-19 02:26 PM
Re: new project...

Just green-lighting here.

Was thinking if you pushed this little vbs scriptlet to the target wkstn (to the root of c:\) ...

code:
dim ans

ans = InputBox("Hello")

This scriptlet could be changed to accept input parms to specify things like title and prompt, then ran this script from your machine:

code:
Break On

$WKSTN = "tassie-xp"

$Process = GetObject("winmgmts:{impersonationLevel=impersonate}!" +
"\\$WKSTN\root\cimv2:Win32_Process" )

$Process.Create("wscript.exe c:\ibox.vbs")

exit 1

Then maybe (like was just mentioned) use the registry or INI file to pipe back the reponse ...


ShawnAdministrator
(KiX Supporter)
2002-11-19 02:31 PM
Re: new project...

Or even better - isn't there a way using remote wmi (or remote shell/WSHPipe) to capture the remote shell output into a string, and bypass the need for a intermediate regpoke or file ?

Chris S.
(MM club member)
2002-11-19 02:46 PM
Re: new project...

Did you guys look at my code above? Take out the GUICopy part and that is what I'm doing.

ShawnAdministrator
(KiX Supporter)
2002-11-19 02:50 PM
Re: new project...

Chris, is there a way to have the wmi process create method wait for the remote proc to finish, instead of returning immediately ? Otherwise, might have to build in some kinda semiphore flag wait loop thingy which is always a bag.

[ 19. November 2002, 14:51: Message edited by: Shawn ]


Chris S.
(MM club member)
2002-11-19 05:31 PM
Re: new project...

Probably. My rmt_exec example is very crude. I think that Rad's has a better one in that it returns the PID of the remote process. Then it would just be a matter of monitoring the remote process and waiting for it to exit before continuing.

Radimus
(KiX Supporter)
2002-11-19 05:32 PM
Re: new project...

can vbscript output to a file or execute an external command?

Chris S.
(MM club member)
2002-11-19 05:37 PM
Re: new project...

Rad, write to file or cmd over the network? Or local (to the remote PC, anyway)?

Network, no. (Unless you're using Kerberos)'

Local, yes.


Radimus
(KiX Supporter)
2002-11-19 05:43 PM
Re: new project...

using shawn's (and your concepts)

do something like:
ans=inputbox("hello")
shell ("kix32 \\server\share\log.kix $$log=ans")


Radimus
(KiX Supporter)
2002-11-19 05:51 PM
Re: new project...

basically, my current project is to push a script out to the client PCs (not during logon) and prompt them to enter some personal account info (phone number, etc) to populate their AD user account.

Since they do not have permission to do it directly, I need to klugde their info a file, so I can verify it and update AD en mass.


Sealeopard
(KiX Master)
2002-11-19 05:57 PM
Re: new project...

Why not separate those two out? Prompt them during login for their info, write it into a .INI file or database. Then once a day, run an admin script against the populated info and update their accounts accordingly. Finally, once a user has entered their info, put a flag on it so they don't get prompted again.

Chris S.
(MM club member)
2002-11-19 06:04 PM
Re: new project...

Here's some psuedo code...
code:
; Remote_Send.kix
; Resides on the remote PC. Is executed using WMI Remote Execute -OR-
; AT.exe -OR- JT.exe... $Requestor is piped in from the command line:
; KiX32.exe Remote_Send.kix $Requestor = "@WKSTA"
;
Break On
SetConsole("Hide")

$Answer=Inputbox("Hello")
$nul = SENDMESSAGE($REQUESTOR,$Answer)

Function Inputbox($Question)
; Your xls inputbox function here...
EndFunction



Radimus
(KiX Supporter)
2002-11-19 06:53 PM
Re: new project...

ok....

I'm going to use soon.exe to schedule the remote job
the remote job will be this kix script:
code:
$=setconsole("minimize")
if not %phonenumber%
$ans=0
while val($ans)<100 or val($ans)>250
$ans = xlsInputBox("Please enter your Phone extension number."+@crlf+"Only enter numbers, Example: 160","Collect Phone Extension")
loop
setm "PhoneNumber=(xxx) 345-7520 x$ans"
endif

and I will use WMIQuery("name","Win32_Environment",$remotepc,"name","PhoneNumber") to push script and/or update AD...