Using variables in WshShell.Run ("....") 
Author Message
 Using variables in WshShell.Run ("....")

    How can I use my variables HomeDIr, UserID within the statement below:
    I tried the code below, but this will end always with an error!

    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Run ("%windir%\system32\cacls" & HomeDir & "\" & UserID & "/E
/G tarsom-eu\" & UserID & ":F")

      Thanks

Rolf



Sat, 25 Jan 2003 03:00:00 GMT  
 Using variables in WshShell.Run ("....")

"Rolf Rettinger" wrote ...

Quote:
>     How can I use my variables HomeDIr, UserID within the statement below:
>     I tried the code below, but this will end always with an error!

>     Set WshShell = CreateObject("WScript.Shell")
>     WshShell.Run ("%windir%\system32\cacls" & HomeDir & "\" & UserID & "/E
> /G tarsom-eu\" & UserID & ":F")

What error? You need to provide a little more information before anyone can
give you a definite reason...

If that is indeed the exact code you are using, however, I can spot at least
two problems from here (well, the same problem twice, anyway...) - there
should be a space after "cacls", and another before the "/E".

If that's not the problem, try just outputting the string inside the
brackets ("%windir%...:F") without passing it to WshShell.Run (e.g. using
MsgBox()), and looking at what get's displayed - you'll probably find
there's something fairly obviously wrong with the command-string.

hth hand

Adam



Sat, 25 Jan 2003 03:00:00 GMT  
 Using variables in WshShell.Run ("....")

Quote:

>     How can I use my variables HomeDIr, UserID within the statement below:
>     I tried the code below, but this will end always with an error!

>     Set WshShell = CreateObject("WScript.Shell")

There is a space needed after cacls to separate it from the file name
that follows and probably one in front of the /E switch to separate it
from the UserID:

     WshShell.Run ("%windir%\system32\cacls " & HomeDir & "\" & _
        UserID & " /E /G tarsom-eu\" & UserID & ":F")

Quote:

>       Thanks

> Rolf

If the HomeDir can have a space or other delimiter in its pathspec, you
will either need to use the shortname version or else enclose it in
quotes as well.  That is, ...

 ... & Chr(34) & HomeDir & Chr(34) & ...

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/



Sat, 25 Jan 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. WshShell.Run "path with spaces" fails

2. "bWaitOnReturn" option for WshShell.Run method

3. Loop print "VARIABLE", "VARIABLE"

4. JavaScript "\"" and WShell Run

5. dynamically dim a variable ie dim "variable"&n

6. Set WSHShell = WScript.CreateObject("WScript.Shell")

7. Set WshShell = CreateObject("WScript.Shell")

8. wshshell.run "rundll.exe wsock32.dll, ...

9. Using a variable within WshShell object and Run method (newbie at work)

10. Acc97: Problems using "Command" variable

11. FindFirst "Date" using variable

12. *"*-.,._,.-*"* I"LL TRADE VISUAL C++ FOR VBASIC *"*-.,_,.-*"*

 

 
Powered by phpBB® Forum Software