(imported topic written by jpf506791)
Hello everyone. This is my first post.
I’m currently an intern at a branch campus of a university and we’re using BigFix for the first time. We have a couple applications installed on a network drive that is mapped using Group Policy. These applications run fine from the network drive with no problem.
Today I was asked to write an ActionScript to deploy a shortcut to our computers. Here is that script:
// Using ActionScript, this will create a new VBScript file, write to it, execute it with cscript, and delete it.
// Begin reading lines and write to the VBScript file. createfile until ENDOFFILE
'Begin VBScript Code
'Create a WshShell Object.
'Allows you to run a program locally,
'manipulate the contents of the registry,
'create a shortcut,
'or access a system folder. set WshShell = WScript.CreateObject(
"WScript.Shell")
'Returns the script of the path to the special folder. Optional.
'strSpecialFolder = WshShell.SpecialFolders("<Select a special folder below.>")
'Available special folders:
'AllUsersDesktop
'AllUsersStartMenu
'AllUsersPrograms
'AllUsersStartup
'Desktop
'Favorites
'Fonts
'MyDocuments
'NetHood
'PrintHood
'Programs
'Recent
'SendTo
'StartMenu
'Startup
'Templates
'Create a WshShortcut Object.
'Can create a new shortcut, or open an existing shortcut.
'If you are using special folders, combine paths with &. Example: strSpecialFolder & "\Shortcut.lnk"
'Be sure that your path includes the name of the shortcut and the lnk extension. Example: "\Shortcut.lnk" set oShellLink = WshShell.CreateShortcut(
"<This is the full path to where the shortcut will be created.>")
'Set the target path of the shortcut. oShellLink.TargetPath =
"<This is the full path to the executable that the shortcut points to>"
'Assign an icon to the shortcut.
'The index is the icon index. If you're pointing to an executable, it should be 0.
'Otherwise, if you're pointing to a dll (shell32.dll), you can specify the icon index. oShellLink.IconLocation =
"<This is the full path to the icon location or the executable.>, 0"
'A short description of the shortcut. Optional.
'oShellLink.Description = "Optional Description"
'Set the window style for the program being run. Optional.
'1 = Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position.
'3 = Activates the window and displays it as a maximized window.
'7 = Minimizes the window and activates the next top-level window.
'oShellLink.WindowStyle = 1
'Commit the changes to the shortcut and save it to the path. oShellLink.Save
'Clean up the WshShortcut Object. set oShellLink = Nothing ENDOFFILE
// The previous line stops writing to the VBScript file.
// Copy the newly created file to a filename that has a .vbs extension. copy __createfile CreateShortcut.vbs
// Execute the VBScript silently using cscript.exe waithidden cscript.exe CreateShortcut.vbs
// Delete the VBScript we just created. delete CreateShortcut.vbs
The VBScript portion of the code works fine when run locally on the machines.
The problem I am having is when this is deployed, if the target for the shortcut has a space (Example: “O:\Program Files”), the space is replaced with an underscore. This does not happen when just the VBScript portion is executed, so I am guessing its the way ActionScript is parsing the file. I have tried the hex value (%20) for the space, but that caused the deployment to fail.
Does anyone have any suggestions to fix this problem?
Thanks,
- Jeff