Jump to content
Sign in to follow this  
megaservo

Rename shortcut in Desktop folder under each user profile in target system

Recommended Posts

megaservo

Im new to the forum....

So our staff have a constant need to compress a massive amount of photos, so I'm looking at the simplest free option for mass image file compression. 

I'm exploring the use of this free tool called Fast Image Resizer (http://adionsoft.net/fastimageresize/

Problem with this litle program is that it dumps an individual Desktop shortcut called FastImageResizer under each user profile's Desktop folder. 

Need some help with this. 

I want to rename each of those individual copies or remove them and copy 1 single shortcut in All Users Desktop (which is what I am trying to achieve in script below) 

Here is my script so far but having trouble geting rid of the old shortcut in every single user profile:

$ccdesktop = @DesktopCommonDir ;define all users desktop location
RunWait("C:\Software\Compression-ImageResizer\FastImageResizer_098.exe /S", @WindowsDir) ;installs Fast image resizer silently, works fine. 
Sleep(2000)
FileRecycle($ccdesktop & "\FastImageResizer.lnk") ;only removes the shortcut from current users desktop
FileCopy("C:\Software\Compression-ImageResizer\64biticon\Fast Image Resizer.lnk", $ccdesktop, 1)
MsgBox(4096, "CompanyName", "Fast Image Resizer Complete", 2)
Beep(100, 200) ;my sound composition at end of script
Beep(300, 200)
Beep(600, 200)
Beep(800, 200)
Exit

I guess I've been trying to workout a simple way to affect individual user profile folders to cleanup a whole lot of other shortcut mess but havent found anything concrete on how to do it in a script. 

thanks, 

megaservo


in process of thinking....

Share this post


Link to post
Share on other sites
devilman16

I would do it this way:

$folder = StringLeft(@UserProfileDir,StringInStr(@UserProfileDir,"\",0,-1))
$search = FileFindFirstFile($folder&"*")
While 1
    $profile = FileFindNextFile($search)
    If @error Then ExitLoop
    If FileExists($folder&$profile&"\desktop\FastImageResizer.lnk") Then
        FileDelete($folder&$profile&"\desktop\FastImageResizer.lnk")
    EndIf
WEnd
FileClose($search)

Share this post


Link to post
Share on other sites
megaservo

 

I would do it this way:

$folder = StringLeft(@UserProfileDir,StringInStr(@UserProfileDir,"\",0,-1))
$search = FileFindFirstFile($folder&"*")
While 1
    $profile = FileFindNextFile($search)
    If @error Then ExitLoop
    If FileExists($folder&$profile&"\desktop\FastImageResizer.lnk") Then
        FileDelete($folder&$profile&"\desktop\FastImageResizer.lnk")
    EndIf
WEnd
FileClose($search)

 

Yeah, thanks man. Worked perfectly. 

I will be sure to use that method if I ever need to do that sort of cleanup per profile. 

Modified script worked: 

$ccdesktop = @DesktopCommonDir ;define all users desktop location
RunWait("C:\Software\Compression-ImageResizer\Program\FastImageResizer_098.exe /S", @WindowsDir)
Sleep(3000)
;delete copies of FastImageResizer.lnk from every profile, adds a copy ot each Desktop folder.
$folder = StringLeft(@UserProfileDir,StringInStr(@UserProfileDir,"\",0,-1))
$search = FileFindFirstFile($folder&"*")
While 1
    $profile = FileFindNextFile($search)
    If @error Then ExitLoop
    If FileExists($folder&$profile&"\desktop\FastImageResizer.lnk") Then
        FileDelete($folder&$profile&"\desktop\FastImageResizer.lnk")
    EndIf
WEnd
FileClose($search)
;end of deletion of old shortcuts
FileCopy("C:\Software\Compression-ImageResizer\64biticon\Fast Image Resizer.lnk", $ccdesktop, 1)
MsgBox(4096, "CompanyName", "Fast Image Resizer Complete", 2)
Beep(100, 200)
Beep(300, 200)
Beep(600, 200)
Beep(800, 200)
Exit

in process of thinking....

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×