Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scipt is reversing my slashes in switch 1

Status
Not open for further replies.

redlair

Technical User
Jun 29, 2004
54
US
This script creates a GroupWise icon on the desktop and adds the user name and Ipa switch to the target path. The script works fine until you examine the switch. The script is reversing the slashes in the switch to forward slashes not back slashes. What am I missing?

Ron


Option Explicit

Dim r
r = MsgBox("Would you like a shortcut to Notepad?", 36, "Create Shortcut?")
If r = 7 Then
WScript.quit
Else
Dim oshell, fso, Uname, Ipa
Set oshell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Dim shcut, d, dpath, wpath
Dim Swtc

dpath = oshell.SpecialFolders("Desktop")
wpath = "C:\Novell\GroupWise"
Uname = InputBox("Input a username Last_First):", "Staff members user name")
Ipa = InputBox("Input the Ipa address for your building.", "Building Ipa")

Swtc = (wpath + "\GrpWise.exe" & " /@u-" & Uname & " /Ipa-" & Ipa)

Set shcut = oshell.CreateShortcut(dpath & "\" & Uname & " GroupWise.lnk")
shcut.TargetPath = oshell.ExpandEnvironmentStrings(Swtc)
shcut.WorkingDirectory = oshell.ExpandEnvironmentStrings(wpath)
shcut.WindowStyle = 4
shcut.IconLocation = oshell.ExpandEnvironmentStrings(wpath & "\GrpWise.exe, 0")
shcut.Save
End If
 
Why are you using ExpandEnvironmentStrings ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Is that my problem? What should I use?
 
Is that my problem? Should I use something else?
 
There is no need to expand it since that particular variable is not an environment variable. Just set it equal to the variable and see what happens.

i.e.

shcut.TargetPath = Swtc
 
Even when I modify the code as shown below the cript still reverses the slash( / ).

Set shcut = oshell.CreateShortcut(dpath & "\" & Uname & " GroupWise.lnk")
shcut.TargetPath = oshell.ExpandEnvironmentStrings(wpath + "\GrpWise.exe" & " /@u-Uname /Ipa-Ipa")
)
shcut.WorkingDirectory = wpath
shcut.WindowStyle = 4
shcut.IconLocation = (wpath & "\GrpWise.exe, 0")
shcut.Save
End If
 
Hello redlair,

Use arguments property to set arguments.
[tt]
shcut.TargetPath = wpath + "\GrpWise.exe"
shcut.arguments = " /@u-" & Uname & " /Ipa-" & Ipa
[/tt]
regards - tsuji
 
Thank you, all for your help. tsuji - using the arguments property solved the problem.

Redlair
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top