wsh

Get target of Windows .lnk shortcut using “Start in” directory

廉价感情. 提交于 2019-12-03 16:17:31
I am trying to retrieve the target path of a Windows .lnk shortcut, but the "Target" is not an actual file path according to the .lnk file's properties: I am using the IWshRuntimeLibrary and the shortcut object I am accessing is of type IWshShortcut: WshShell shell = new WshShell(); IWshShortcut link = (IWshShortcut)shell.CreateShortcut(lnkFileName); // This returns "C:\Windows\Installer\{F843C6A3-224D-4615-94F8-3C461BD9AEA0}\PaintShopProExeIcon.ico" var targetPath = link.TargetPath; // This is the same as the "Start in" value in the image above var workingDir = link.WorkingDirectory; The

Is it possible to invoke Mathematica's diff functionality from the command line?

烂漫一生 提交于 2019-12-03 14:53:59
TortoiseSVN (as well as other Tortoise clients ) include a script to diff notebook files in Mathematica. Diff functionality for Mathematica is implemented in the AuthorTools package (perhaps there is something better?) The script currently works by creating a small notebook file in the temp directory, and opening it in the front end. The notebook has a big button that will do the diff and has the file names to be diffed hard coded. A disadvantage is that the notebook with the diff code will be left in the temp directory, and won't be cleaned up. It also seems unnecessary to have an auxiliary

Is there a way to run a command line command from JScript (not javascript) in Windows Scripting Host (WSH) cscript.exe?

浪子不回头ぞ 提交于 2019-12-03 14:31:20
I'm writing a JScript program which is run in cscript.exe. Is it possible to run a commnad line command from within the script. It would really make the job easy, as I can run certain commands instead of writing more code in jscript to do the same thing. For example: In order to wait for a keypress for 10 seconds, I could straight away use the timeout command timeout /t 10 Implementing this in jscript means more work. btw, I'm on Vista and WSH v5.7 any ideas? thanx! You can execute DOS commands using the WshShell.Run method: var oShell = WScript.CreateObject("WScript.Shell"); oShell.Run(

JScript Enumerator and list of properties

丶灬走出姿态 提交于 2019-12-03 13:31:44
问题 Consider the following WSH snippet: var query = GetObject("winmgmts:").ExecQuery("SELECT Name FROM Win32_Printer", "WQL", 0); var e = new Enumerator(query); for ( ; !e.atEnd(); e.moveNext ()) { var p = e.item(); WScript.Echo(p.Name + " (" + p.Status + ")"); } It prints in every line a printer name and the word "undefined" in brackets (because Status property isn't exist in p object). The question is: how can I list all available properties from p ? The usual technique with for (var i in p) {.

How do I use jQuery in Windows Script Host?

穿精又带淫゛_ 提交于 2019-12-03 12:03:49
I'm working on some code that needs to parse numerous files that contain fragments of HTML. It seems that jQuery would be very useful for this, but when I try to load jQuery into something like WScript or CScript, it throws an error because of jQuery's many references to the window object. What practical way is there to use jQuery in code that runs without a browser? Update: In response to the comments, I have successfully written JavaScript code to read the contents of files using new ActiveXObject('Scripting.FileSystemObject'); . I know that ActiveX is evil, but this is just an internal

how can I check if a file exists?

巧了我就是萌 提交于 2019-12-03 06:22:59
问题 I want to check to see if a file exists and if it does, I want to open it and read the 1st line, If the file doesn't exist or if the file has no contents then I want to fail silently without letting anyone know that an error occurred. 回答1: Start with this: Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FileExists(path)) Then msg = path & " exists." Else msg = path & " doesn't exist." End If Taken from the documentation. 回答2: For anyone who is looking a way to watch a specific

Classic ASP amazon s3 rest authorisation

烂漫一生 提交于 2019-12-03 05:52:41
I am confused on what I am doing wrong here... <script language="javascript" runat="server"> function GMTNow(){return new Date().toGMTString()} </script> <% Const AWS_BUCKETNAME = "uk-bucketname" Const AWS_ACCESSKEY = "GOES HERE" Const AWS_SECRETKEY = "SECRET" LocalFile = Server.Mappath("/test.jpg") Dim sRemoteFilePath sRemoteFilePath = "/files/test.jpg" 'Remote Path, note that AWS paths (in fact they aren't real paths) are strictly case sensitive Dim strNow strNow = GMTNow() ' GMT Date String Dim StringToSign StringToSign = Replace("PUT\n\nimage/jpeg\n\nx-amz-date:" & strNow & "\n/"& AWS

Creating Shortcut where folder name is having unicode characters

我与影子孤独终老i 提交于 2019-12-02 20:09:26
问题 I have been using the below code to create shortcuts dynamically. But the targetPath throws Argument exception when the folder name has unicode characters like Thai,greek language. IWshRuntimeLibrary.WshShell shell = new WshShell(); IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutLocation); shortcut.Description = "My shortcut description"; // The description of the shortcut shortcut.WorkingDirectory = currentPath; shortcut.TargetPath = targetFileLocation; // The path of the

vbscript code to read input from text file avoiding manual efforts

旧街凉风 提交于 2019-12-02 18:20:30
问题 I am drilling down Internet to get Vbscript code, where input is read from text file one per line and pass it to the commands in script. I am just a beginner and need help with this. Basically I am gathering script to get pending patches of servers in our environment. The script looks like below: '# '# ServerPendingUpdates.vbs '# '# Usage: cscript ServerPendingUpdates.vbs {servername} {servername} {servername} {servername} '# If no {servername} specified then 'localhost' assumed '# '# To do:

Change Console Title with vbscript

醉酒当歌 提交于 2019-12-02 13:51:34
问题 is there a way to change the cmd title? I wrote a vbs program. But the dos title is bad. The name ist c:\windows\system32\cscript.exe I try it with: title the_name and title ="name" But both doesn't works. Thanks for help. 回答1: Unfortunately you cannot do that from within the script using any of the WSH objects. The only way to do it is to launch the script via an intermediary (a .bat using the TITLE command or another script using a %comspec% argument). 回答2: @AlexK The link you point to