Announcement

Collapse
No announcement yet.

Simple question: How do I refereence the current directory were the script is run fro

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Simple question: How do I refereence the current directory were the script is run fro

    Here is my script I am trying to get it to use an .ICO icon file as the icon for the shortcut. It will be in the same directory as the script. right now it is not working. Any and all help will be greatly appreciated





    Set WshShell = CreateObject("WScript.Shell")
    set objFSO = CreateObject("Scripting.FileSystemObject")

    strDesktop = WshShell.SpecialFolders("Desktop")

    IF Not objFSO.FileExists(strDesktop & "\DesktopIconName.lnk") THEN
    set oShellLink = WshShell.CreateShortcut(strDesktop & "\DesktopIconName.lnk")
    oShellLink.TargetPath = "http://WebSiteAddress"
    oShellLink.WindowStyle = 1
    oShellLink.IconLocation = "dqrc.ico"
    oShellLink.Description = "DesktopIconDescription"
    oShellLink.WorkingDirectory = "http://WebSiteAddress"
    oShellLink.Save
    set oShellLink = NOTHING
    END IF
    ________
    XexoticCarianeX live
    Last edited by meterman; 16th August 2011, 12:16.

  • #2
    Re: Simple question: How do I refereence the current directory were the script is run

    You will need to copy the icon file locally anyway.

    If you place it in %SYSTEMROOT%, then the path variabel will pick up the file without havign to specific a direct path.

    Topper
    * Shamelessly mentioning "Don't forget to add reputation!"

    Comment


    • #3
      Re: Simple question: How do I refereence the current directory were the script is run fro

      FSO.ParentFolder(WScript.ScriptFullPathName) will give you the folder the script is in, but not the path it was run from - but wouldn't that only be relevant if you were running it from the command line?

      Comment


      • #4
        Re: Simple question: How do I refereence the current directory were the script is run fro

        THis is a logon script. It will be placed in a network share, which should replicate to various domain controllers accross different sites. so the .ico file needs to be on the share not in the System root. Here is what I have, But it is still not working.

        Set WshShell = CreateObject("WScript.Shell")
        set objFSO = CreateObject("Scripting.FileSystemObject")

        strDesktop = WshShell.SpecialFolders("Desktop")

        IF Not objFSO.FileExists(strDesktop & "\DesktopIconName.lnk") THEN
        set oShellLink = WshShell.CreateShortcut(strDesktop & "\DesktopIconName.lnk")
        oShellLink.TargetPath = "http://WebSiteAddress"
        oShellLink.WindowStyle = 1
        oShellLink.IconLocation = "FSO.ParentFolder(WScript.ScriptFullPathName)\dqrc.ico"
        oShellLink.Description = "DesktopIconDescription"
        oShellLink.WorkingDirectory = "http://WebSiteAddress"
        oShellLink.Save
        set oShellLink = NOTHING
        END IF

        Set WshShell = NOTHING
        Set objFSO = NOTHING
        ________
        Web Shows
        Last edited by meterman; 16th August 2011, 12:17.

        Comment


        • #5
          Re: Simple question: How do I refereence the current directory were the script is run fro

          in a batch it would be somthing like %0\..\dqrc.ico
          What is the vbs equivilent? can this be used to refernce my ICO file/
          Thanks
          ________
          Maurizz
          Last edited by meterman; 16th August 2011, 12:17.

          Comment


          • #6
            Re: Simple question: How do I refereence the current directory were the script is run fro

            help please!
            ________
            Evia
            Last edited by meterman; 16th August 2011, 12:17.

            Comment


            • #7
              Re: Simple question: How do I refereence the current directory were the script is run fro

              where does the dqrc.ico located?
              Marcel
              Technical Consultant
              Netherlands
              http://www.phetios.com
              http://blog.nessus.nl

              MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
              "No matter how secure, there is always the human factor."

              "Enjoy life today, tomorrow may never come."
              "If you're going through hell, keep going. ~Winston Churchill"

              Comment


              • #8
                Re: Simple question: How do I refereence the current directory were the script is run fro

                OK I figured out that topper was right I do need to copy the icon to the clients system root. So, Now what I need to do is copy the .ico file from the netlogon folder of the server the client logged into to the clients syystm root.
                Here is what I tried to write but it is not working. Any Ideas what I am missing>?



                Set WshShell = CreateObject("WScript.Shell")
                set objFSO = CreateObject("Scripting.FileSystemObject")
                strDesktop = WshShell.SpecialFolders("Desktop")
                systemroot = WshShell.SpecialFolders("systemroot")

                IF Not objFSO.FileExists(strDesktop & "\digitalqrc.lnk") THEN
                set oShellLink = WshShell.CreateShortcut(strDesktop & "\digitalqrc.lnk")
                oShellLink.TargetPath = "http://www.digitalqrc.com"
                oShellLink.WindowStyle = 1
                OBJfso.CopyFile "%LOGONSERVER%\netlogon\dqrc.ico" , "%systemroot%\DQRC.ico" ,TRUE
                oShellLink.IconLocation = "%systemroot%\DQRC.ico"
                oShellLink.Description = "digitalqrc"
                oShellLink.Save
                set oShellLink = NOTHING

                END IF
                Set WshShell = NOTHING
                Set objFSO = NOTHING
                ________
                VOLCANO CLASSIC REVIEW
                Last edited by meterman; 16th August 2011, 12:18.

                Comment


                • #9
                  Re: Simple question: How do I refereence the current directory were the script is run fro

                  This can problably work

                  Code:
                  'Declare and set variables.
                  Dim WshShell, ObjFSO,StrDesktop,Systemroot,LogonServer, oShellLink 
                  Set WshShell = CreateObject("WScript.Shell")
                  set objFSO = CreateObject("Scripting.FileSystemObject")
                  strDesktop = WshShell.SpecialFolders("Desktop")
                  systemroot = WshShell.ExpandEnvironmentStrings("%Systemroot%")
                  LogonServer = WshShell.ExpandEnvironmentStrings ("%LogonServer%")
                  
                  IF objFSO.FileExists(strDesktop & "\digitalqrc.lnk")= False  Then
                  	set oShellLink = WshShell.CreateShortcut(strDesktop & "\digitalqrc.lnk")
                  	oShellLink.TargetPath = "http://www.digitalqrc.com" 
                  	oShellLink.WindowStyle = "1" 
                  	OBJfso.CopyFile LogonServer & "\Netlogon\dqrc.ico" , Systemroot & "\DQRC.ico" ,True
                  	oShellLink.IconLocation = Systemroot & "\DQRC.ico"
                  	oShellLink.Description = "digitalqrc" 
                  	oShellLink.Save	
                  END If
                  
                  'cleanup
                  set oShellLink = Nothing
                  Set WshShell = NOTHING
                  Set objFSO = NOTHING
                  Marcel
                  Technical Consultant
                  Netherlands
                  http://www.phetios.com
                  http://blog.nessus.nl

                  MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
                  "No matter how secure, there is always the human factor."

                  "Enjoy life today, tomorrow may never come."
                  "If you're going through hell, keep going. ~Winston Churchill"

                  Comment


                  • #10
                    Re: Simple question: How do I refereence the current directory were the script is run fro

                    I am going to try it now, I see then I needed to define %systemroot% to use it.
                    I supose now I am going to have to really read up so in the future I can do this.Well I did learn a lot so far.

                    Thanks so much for your help
                    ________
                    Medical Dispensaries
                    Last edited by meterman; 16th August 2011, 12:19.

                    Comment


                    • #11
                      Re: Simple question: How do I refereence the current directory were the script is run fro

                      IT WORKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!
                      Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you,
                      ________
                      Colorado dispensaries
                      Last edited by meterman; 16th August 2011, 12:19.

                      Comment


                      • #12
                        Re: Simple question: How do I refereence the current directory were the script is run fro

                        without any adjustment? wow, i almost starting scared about myself

                        you're welcome anyway
                        Marcel
                        Technical Consultant
                        Netherlands
                        http://www.phetios.com
                        http://blog.nessus.nl

                        MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
                        "No matter how secure, there is always the human factor."

                        "Enjoy life today, tomorrow may never come."
                        "If you're going through hell, keep going. ~Winston Churchill"

                        Comment

                        Working...
                        X