Page 1 of 2 12>
Topic Options
#89515 - 2002-11-14 09:22 PM new project...
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
how to remotely push an input box and return the entered value...
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#89516 - 2002-11-14 09:33 PM Re: new project...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
you mean something like NET SEND, in reverse:

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

tricky ...

Top
#89517 - 2002-11-14 09:35 PM Re: new project...
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
Yep, that is what I would like...
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#89518 - 2002-11-14 09:39 PM Re: new project...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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...
_________________________
!

download KiXnet

Top
#89519 - 2002-11-14 09:45 PM Re: new project...
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
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
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#89520 - 2002-11-14 10:45 PM Re: new project...
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
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=""


Top
#89521 - 2002-11-19 01:38 PM Re: new project...
Will Hetrick Offline
Hey THIS is FUN

Registered: 2001-10-02
Posts: 320
Loc: Harrisburg, PA USA
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"



_________________________
You have at least 2 choices. Each choice changes your destiny. Choose wisely!

Top
#89522 - 2002-11-19 01:42 PM Re: new project...
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
That wouldn't work if I sent the code out to 50 PCs at a time...
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#89523 - 2002-11-19 01:56 PM Re: new project...
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Rad,

Using the example of -

echo y | del .

Can't you do the same thing?

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

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#89524 - 2002-11-19 02:06 PM Re: new project...
Will Hetrick Offline
Hey THIS is FUN

Registered: 2001-10-02
Posts: 320
Loc: Harrisburg, PA USA
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

_________________________
You have at least 2 choices. Each choice changes your destiny. Choose wisely!

Top
#89525 - 2002-11-19 02:09 PM Re: new project...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
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 ...

Top
#89526 - 2002-11-19 02:17 PM Re: new project...
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
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 ]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#89527 - 2002-11-19 02:23 PM Re: new project...
Will Hetrick Offline
Hey THIS is FUN

Registered: 2001-10-02
Posts: 320
Loc: Harrisburg, PA USA
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

_________________________
You have at least 2 choices. Each choice changes your destiny. Choose wisely!

Top
#89528 - 2002-11-19 02:26 PM Re: new project...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
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 ...

Top
#89529 - 2002-11-19 02:31 PM Re: new project...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
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 ?
Top
#89530 - 2002-11-19 02:46 PM Re: new project...
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Did you guys look at my code above? Take out the GUICopy part and that is what I'm doing.
Top
#89531 - 2002-11-19 02:50 PM Re: new project...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
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 ]

Top
#89532 - 2002-11-19 05:31 PM Re: new project...
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
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.
Top
#89533 - 2002-11-19 05:32 PM Re: new project...
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
can vbscript output to a file or execute an external command?
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#89534 - 2002-11-19 05:37 PM Re: new project...
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
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.

Top
Page 1 of 2 12>


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 202 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.221 seconds in which 0.166 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org