wsh

Opening a File whose Name Contains a Space

不问归期 提交于 2019-12-10 04:19:12
问题 I have some simple Excel VBA code that opens non-Excel files like: Sub scriptTest() Set objshell = CreateObject("Wscript.Shell") objshell.Run ("C:\TestFolder\Book1.pdf") Set objshell = Nothing End Sub Running this opens the file in the Acrobat Reader. However if I try to open a file whose name contains a space character like: Sub scriptTest() Set objshell = CreateObject("Wscript.Shell") objshell.Run ("C:\TestFolder\Bo ok1.pdf") Set objshell = Nothing End Sub I get: Both files open fine if I

WScript in VB.NET?

送分小仙女□ 提交于 2019-12-09 17:30:04
问题 This is a snipet of code from my program: WSHShell = WScript.CreateObject("WScript.Shell") But for some reason, "WScript" is not declared. I know that this code works in VBScript but i'm trying to get it to work with vb.net. Whats going wrong? 回答1: The WScript object is specific to Windows Script Host and doesn't exist in .NET Framework. Actually, all of the WScript.Shell object functionality is available in .NET Framework classes. So if you're porting VBScript code to VB.NET, you should

CScript and VBS to Remove Line Breaks from Text File

ぃ、小莉子 提交于 2019-12-09 11:03:41
问题 I have a batch file running which spits out a text/html file. The batch file is causing some line breaks in the text file, which do not translate very well in opening the file in an email. I have been trying to read up on CScript to create a vbs script that can read the text file and strip out the line breaks but have had no luck. Any advice? 回答1: Not sure how you'd prefer to do it, but this script takes a filename as an argument and writes the results to the same file. Const ForReading = 1,

Windows Script Host (jscript): how do i download a binary file?

有些话、适合烂在心里 提交于 2019-12-09 06:22:27
问题 i'm trying to automate a file download with Windows Script Host (JScript). i see ADODB.Stream has an Open method whose documentation makes it seem like it should be possible to open a HTTP URL and stream the response body: var url = 'http://example.com/example.tar.gz'; var path = 'example.tar.gz'; var input = WScript.CreateObject('ADODB.Stream'); input.Open(url); input.SaveToFile(path); input.Close(); But it bombs on the Open call with (null): Object or data matching the name, range, or

Can't upload a file to FTP with WScript.Shell / cmd [duplicate]

自作多情 提交于 2019-12-08 10:56:09
问题 This question already has answers here : 200 PORT command successful. Consider using PASV. 425 Failed to establish connection (4 answers) Getting “I won't open a connection to” when connecting to FTP server from Google Compute Engine (3 answers) Closed last year . I've created simple HTA-page <input type="button" value="Run" onclick="run();"> <script> function run() { var shell = new ActiveXObject('WScript.Shell'); shell.run('cmd /c ftp -i -s:D:\ftp.bat',0,true); } </script> And on my disk D

Is it possible to programatically change an msi's database on Linux

六月ゝ 毕业季﹏ 提交于 2019-12-08 08:39:21
I know you can change it using cscript.exe on Windows. Is there a Linux program providing cscript-like functionality? Or is there some other way I can change the database in Linux? CScript is just the script execution engine; it knows nothing about MSI directly. Check out Wine; it implements some/most of msi.dll, so as long as functions like MsiDatabaseOpenView and MsiViewExecute are correctly implemented, you should be able to use it to modify an .msi package. 来源: https://stackoverflow.com/questions/7115086/is-it-possible-to-programatically-change-an-msis-database-on-linux

Remote Powershell popup message

怎甘沉沦 提交于 2019-12-08 05:28:21
问题 I'm attempting to create a remote powershell popup window to any users logged into a target computer. I have found a simple script that does create a popup window: (New-Object -ComObject wscript.shell).popup("THIS IS A TEST MESSAGE") However, I cannot run this script on remote devices. We have powershell remoting restricted in our environment so I cannot use the invoke-command cmdlet in powershell. I have bypassed this restriction in the past by using the Invoke-WmiMethod cmdlet and creating

cscript.exe opens a window

孤者浪人 提交于 2019-12-08 03:45:23
问题 I have a vbs file that need to be run in 32-bit, even though I am running Windows 7 64-bit. I can launch this file with the command C:\Windows\SysWOW64\cscript.exe my-file.vbs and that works fine, but it leaves me with a redundant command prompt window that I have to close manually each time. It also makes it very cumbersome to run this vbs-file as a startup item. Is there a way to start my 32-bit vbs-file in the background? 回答1: Try this for the 64bit problem, if it works you can combine it

Use VBScript to Merge all open instances of Notepad.exe and save to txt file

扶醉桌前 提交于 2019-12-07 20:37:27
I am looking for a way in vbscript to find any open instances of notepad.exe, copy the text from them and create a new file that contains the contents of all of them and save it. I have worked out the code to actually find the running instances, just can't work out a way to copy the text out of them! Dim objWMIService, objProcess, colProcess,WshShell Dim strComputer, strList strComputer = "." Set WshShell = WScript.CreateObject("WScript.Shell") Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colProcess = objWMIService

WSH scripts unit testing framework [closed]

こ雲淡風輕ζ 提交于 2019-12-07 06:59:02
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I'm looking for a unit testing framework for WSH scripts (vbs/wsf, not VB6, VBA). I can't find anything except this project (looks good, but last activity was recorder around 2 years ago, haven't tested it yet): http://code.google.com/p/vbslib/ Thanks! 回答1: There also is ScriptUnit and if you just google for