Replacing value inside of busted url

(imported topic written by rdamours91)

Our web programmers have programmed a beautiful page that works with none of the links on our 20,000 workstations.

I’m trying to replace the innards of the url with correct value and this is how far I have gotten.

See if the files exists first

Q: exists file (“C:\Documents and Settings” & (name of current user) & “\Favorites\Links\District Links\Orbit.url”)

A: True

Return the value of the url currently

Q: following texts of firsts “URL=” of lines whose (it as lowercase starts with “url=”) of file “orbit.url” of folder (“C:\Documents and Settings” & (name of current user) & “\Favorites\Links\District Links”)

A: https://its.epsb.ca/orbit/login.cfm

The value need to be https://its.epsb.ca/orbit

I’d like to be able to check to see the file exists and if it is currently wrong then change it out to the correct version. Just wondering if I replace the whole file if it exists or try to change the contents.

It’s only been about a half hour since discovered so so far so good. Just wondering how to smash the two together inside of a exists file whose kind of statement.

(imported comment written by rdamours91)

I dug a little deeper and found this http://forum.bigfix.com/viewtopic.php?id=2147 which looks a lot like what I’m trying to do.

Isn’t it funny that this kind of work that is not of your doing is always an emergency.

Here’s the content of the dos edited file as I’m staring at it.

DEFAULT

BASEURL=https://its.epsb.ca/orbit/login.cfm

InternetShorcut

URL=https://its.epsb.ca/orbit/login.cfm

Modified=8048and a bunch other numbers

Looks like I got the Relevance

Here’s my relevance that I’m returning via qna

Q: exists file (“C:\Documents and Settings” & (name of current user) & “\Favorites\Links\District Links\Orbit.url”) whose (exists lines whose (it as lowercase contains “https://its.epsb.ca/orbit/login.cfm”)of it )

A: True

Now for the action script…

(imported comment written by SystemAdmin)

I have to ask an obligatory question-- are these computers in AD? If there are, it would be much easier to do this with group policy. That being said, my company has thousands of machines that are not part of our AD structure. We use the IE auto-configuration script with good results and that might be an option to examine.

I haven’t taken the closest look at what you wrote, but I can tell you that you right away that you are going to run into issues with profile folders that are not the same as the user name. This occurs when you change a user name after the profile has been created, or a profile becomes corrupt and a second one is created with .001 after the name, or if there is a local account and domain account of the same name, so you end up with C:\Documents & Settings\username.domain\ as the folder. Anyway, this is more than a rare occurrence and you need to compensate for it.

This code will help, but it is ugly:

value of variable "SystemDrive" of environment & ((following text of first "e%25" of it)of (preceding text of last "%00" of it) of (value "ProfileImagePath" of key ("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\" & (component string of sid of local user "administrator")) of registry as string))

More info on this is available in this thread:

http://forum.bigfix.com/viewtopic.php?id=3784

Good luck!

(imported comment written by rdamours91)

Got it… Thanks for the info Brian as it will be very useful. This was just a quick brute force update to temporarily fix a problem.

I’ll have to give it a good going over at a later date for a solution that is more elegant.

Action Script

Script Type BigFix Action Script

// store the file location – store the file location or (“C:\Documents and Settings” & (name of current user) & “\Favorites\Links\District Links\Orbit.url”)

parameter “filename” = “{pathname of file (“C:\Documents and Settings” & (name of current user) & “\Favorites\Links\District Links\Orbit.url” ) }”

parameter “textToReplace” = “https://its.epsb.ca/orbit/login.cfm

parameter “newText” = “https://its.epsb.ca/orbit

// iterate through the file replacing lines as necessary

appendfile {concatenation “%0d%0a” of ( if (it contains (parameter “textToReplace”)) then ((preceding text of first (parameter “textToReplace”) of it) & (parameter “newText”) & (following text of first (parameter “textToReplace”) of it) ) else it ) of lines of file (parameter “filename”)}

// backup the old file

// move “{parameter “filename”}” “{parameter “filename”}.bak”

delete “{parameter “filename”}”

// replace with the new file

move __appendfile “{parameter “filename”}”

I too have a busted URL - One of the ports on the link changed and I’m trying to change it on All User’s favorites - I believe I have parameter “filename” incorrect - sorry new to Big Fix assistance needed Here is my action script below:
// store the file location – store the file location or (“C:\Users” & (name of current user) & “\Favorites\SAP\SAP BW Reports.url”)
parameter “filename” = “{pathname of file (“C:\Users” & (name of current user) & “\Favorites\SAP\SAP BW Reports.url” ) }”

parameter “textToReplace” = "http://tasapprd.ta.com:8100/sap/bc/bsp/sap/z_web_menu"
parameter “newText” = “http://tasapprd.ta.com:8105/sap/bc/bsp/sap/z_web_menu

// iterate through the file replacing lines as necessary
appendfile {concatenation “%0d%0a” of ( if (it contains (parameter “textToReplace”)) then ((preceding text of first (parameter “textToReplace”) of it) & (parameter “newText”) & (following text of first (parameter “textToReplace”) of it) ) else it ) of lines of file (parameter “filename”)}

// backup the old file
// move “{parameter “filename”}” "{parameter “filename”}.bak"
delete “{parameter “filename”}”
// replace with the new file
move __appendfile “{parameter “filename”}”