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

Working directory.. 1

Status
Not open for further replies.

HitechUser

Programmer
Oct 19, 2004
560
US
All,

Is it possible to change the "Working" and "Cmd line" attributes (or any other) of a .PIF file (DOS program) in a VBScript?

If so, can you please provide a code example and /or a web link?

I have searched the forum and web yet I only found a way to change these values for shortcuts.


Thanks in advance
 
Hello HitechUser,

It is possible as long as it cmd line (the targetpath) remains a win16 console application. Suppose it is existing a pif, say abc.pif. You now create on shortcut abc.lnk with only setting change be workingdirectory. When you save it, it will automatically named to abc.pif and inherit the existing settings as well. (The point is you cannot do it without tempering the engine to believe it's an .lnk file at the start.)
Code:
spiffile="d:\test\abc.pif"    'you existing settings be there
snewworkingdirectory="d:\test"    'new setting to change

slnkfile=replace(spiffile,".pif",".lnk")
set wshshell=createobject("wscript.shell")
set olnk=wshshell.createshortcut(slnkfile)
olnk.workingdirectory=snewworkingdirectory
olnk.save
set olnk=nothing
set wshshell=nothing
regards - tsuji
 
-Amendments-

One key factor I forget to put into the script is to assert again the win16 console application targetpath. If the existing targetpath is "c:\windows\command.com", you have to repeat this setting. Or, it is even possible to change the command line as long as it stay being win16 console.

This is a relist of a working minimal script.
Code:
spiffile="d:\test\abc.pif"    'your existing settings be there
snewworkingdirectory="d:\test"    'new setting to change
[green]stargetpath="c:\windows\command.com"    'new or unchanged win16 console[/green]

slnkfile=replace(spiffile,".pif",".lnk")
set wshshell=createobject("wscript.shell")
set olnk=wshshell.createshortcut(slnkfile)
[green]olnk.targetpath=stargetpath    'must be explicitly repeated here[/green]
olnk.workingdirectory=snewworkingdirectory
olnk.save
set olnk=nothing
set wshshell=nothing
- tsuji
 
tsuji,

I have searched the Internet (including MSDN, TechNet, etc.) and could not find any results.

Your example worked perfectly. Also I appriciate your follow-up note. This example is a "keeper".

You TOTALLY rock!!! I can't thank you enough!!!

All the best...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top