Solved

Using a Network PAth as a Variable with the Shell function

Posted on 2004-08-09
3
240 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
  • 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 250 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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

809 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