Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using a Network PAth as a Variable with the Shell function

Posted on 2004-08-09
3
Medium Priority
?
245 Views
Last Modified: 2010-05-02
Ok guys i know this is probably simple one, i just cant figure it out.

I'm using the shell function to run a third party utility called "psexec" to exectue programs on remote machines. I'm trying to find a way of setting the remote computer name as a variable, which is passed from a text box to a shell command, but i just cant get it too work. i've tried the following.

All i want is to pass a text box entry to the variable called "remotepc", which i can use the "shell" function.

Private Sub Command1_Click()

Dim remotepc as string
dim params as string

text1.text = remotepc
params = "-i -c -f -d \\Server1\test\client.exe"

Form1.Hide
Shell "\\server1\users\ribuck\everyone\Antivirus\psexec.exe" & remotepc & params

Unload Me

End Sub


0
Comment
Question by:ribuck
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 14

Expert Comment

by:Farzad Akbarnejad
ID: 11751010
Hi,
Write  remotepc = text1.text   instead of   text1.text = remotepc  because you can assign value from textbox to remotepc.

-FA
0
 
LVL 14

Expert Comment

by:Farzad Akbarnejad
ID: 11751013
** because you want  ....   **

-FA
0
 
LVL 18

Accepted Solution

by:
Sethi earned 1000 total points
ID: 11751217
This is how you do it:

Private Sub Command1_Click()

Dim remotepc as string
dim params as string

remotepc = text1.text
params = "-i -c -f -d \\Server1\test\client.exe"

Form1.Hide
Shell "\\server1\users\ribuck\everyone\Antivirus\psexec.exe " & remotepc & " " & params

Unload Me

End Sub

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question