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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with a script 1

Status
Not open for further replies.

max8699

IS-IT--Management
Nov 14, 2006
236
0
0
AU
Hi Guys,
I'm still very new to scripting so need some plain language advice on a solution.
Below is a script i'm using to send shortcuts to desktops around the network. Works great however on the Line strAppPath = i want to add a np switch, this stops students printing a forrest. However whenever i add the switch the shortcut no longer works and when i click on short cut properities on the client pc, the "" are added to the start and end of the Target path line.
If i manually go in and remove the "" then it all works correctly.
Any ideas on how to add the np switch and not have the commas show at the start and end of the line
' --------------------------------------------------
' Here are the variables that to change if you are making a 'real' script

strWorkDir ="\\studentserver\CMEplus"
strAppPath ="\\studentserver\cmeplus\Cmeplus.exe"
strIconPath ="\\studentserver\CMEplus\CMEplus.exe"

Set objShell = CreateObject("WScript.Shell")
objDesktop = objShell.SpecialFolders("Desktop")
Set objLink = objShell.CreateShortcut(objDesktop & "\Library Search.lnk")

This is not the full Script of course i can post the full script if needed.

Regards
Max
Never argue with an idiot, they drag you down to their level and beat you with experience
 
How does the switch get passed? Is it a -np or a \np or what?
 
hi mrjoshd
i put /np at the end of the line it all works just not in the script.

Regards
Max
Never argue with an idiot, they drag you down to their level and beat you with experience
 
Can you please post the full script if possible? The method you are using should not be passing the quotes through to the shortcut.
 
Spoke too soon...

Add the line strAppSwitch = " /np"

And in the section where you are declaring the key properties add this line as well.

objLink.Arguments = strAppSwitch

Apparently arguments can't be passed because they are their own property and that's why anything with a space for the targetpath is always enclosed in quotes to ensure the targetpath is passed correctly.
 
Hi mrjoshd, Thanks for the reply
Ok Here is the full script When i add in the 2 line as you suggested i get an error
Variable is undefined: 'strAppSwitch'
Where do i add your suggestions? I Added them under each section as per below

' CreateShortCut.vbs - Create a Desktop Shortcut.
' VBScript to create .lnk file
' Author Guy Thomas ' Version 2.4 - July 2006
' ----------------------------------------------------------'
Option Explicit
Dim objShell, objDesktop, objLink
Dim strAppPath, strWorkDir, strIconPath

' --------------------------------------------------
' Here are the variables that to change if you are making a 'real' script

strWorkDir ="\\192.168.25.9\library\CMEplus"
strAppPath ="\\192.168.25.9\library\cmeplus\Cmeplus.exe"
strIconPath ="\\192.168.25.9\library\CMEplus\CMEplus.exe"
strAppSwitch = " /np"

Set objShell = CreateObject("WScript.Shell")
objDesktop = objShell.SpecialFolders("Desktop")
Set objLink = objShell.CreateShortcut(objDesktop & "\Library Search.lnk")

' ---------------------------------------------------
' Section which adds the shortcut's key properties

objLink.Description = "\\192.168.25.9\library\CMEplus"
objLink.HotKey = "CTRL+SHIFT+X"
objLink.IconLocation = strIconPath
objLink.TargetPath = strAppPath
objLink.WindowStyle = 3
objLink.WorkingDirectory = strWorkDir
objLink.Arguments = strAppSwitch
objLink.Save

WScript.Quit

' End of creating a desktop shortcut

Regards
Max
Never argue with an idiot, they drag you down to their level and beat you with experience
 
My apologies. If Option Explicit is defined then each variable must be initiated (such as Dim objShell, objDesktop, objLink). You can either take the Option Explicit line out which will let you use variables on the fly or simply add on StrAppSwitch like this:

Dim strAppPath, strWorkDir, strIconPath, strAppSwitch

That will take care of your error. Those lines I gave you earlier were added correctly and it should function just fine.
 
Many Many Thanks mrjoshd you are a champion
have a star.[2thumbsup]

Regards
Max
Never argue with an idiot, they drag you down to their level and beat you with experience
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top