windows-shell

Why does TypeName() return different results from .GetType and TypeOf when working with COM?

强颜欢笑 提交于 2019-12-12 03:19:07
问题 I feel like I would benefit greatly from understanding the differences in how these functions work so that I could better understand when to use each one. I'm having a very difficult time working with two different interops (Excel, and EPDM) which have both made extensive use of weak typed parameters. I keep running into problems using returned objects and casting them to the proper type (per the documentation). After wasting a ton of time, I've found that using TypeName, GetType, and a

Replace Program Files with Progra~1 in a shell script

最后都变了- 提交于 2019-12-12 00:36:33
问题 I would like to have a script/command that will replace all the occurrences of "Program Files" with the no space Progra~1 win a windows shell script on XP Is there a way in the XP shell to do this? I have been searching and can't find any examples sudo CURRENT_PATH=%PATH% NEW_PATH= replace all "Program Files" with Progra~1 I will then use setx to set the new path 回答1: You can use the simple dos command below in your script set p = %PATH% set CLEAN_PATH=%p:Program Files=Proga~1% echo CLEAN

python running batch file with administartor rights by subprocess to change ip

北城以北 提交于 2019-12-11 19:38:58
问题 I want to run a batch file which changes my ip address by static // sth.bat netsh int ip set address "Wifi" static xxxx.xxxx.xxxx.xxxx 255.255.255.0 xxxx.xxxx.xxxx.x 1 changing the ip address requires administrator rights so i want to use the subprocess module to run the file as admin by the following python module // ip_changer.py import subprocess,time,socket from subprocess import PIPE,STDOUT p = subprocess.Popen("runas /user:Administrator \"C:/Users/userName/sth.bat\"", shell = True,

Trying to get default web browser path fails on Windows 10

喜你入骨 提交于 2019-12-11 16:16:53
问题 I'm doing the following in my app's installer (note that the installer for this project is just a Windows executable ( setup.exe ) and not an MSI.) First I needed to check if there're file associations for .htm and .html file types. I did so already. And then if there's no association I needed to add them to be opened by a web browser. To make a lesser of an impact on a user's system, I thought to go with the user's default web browser. The question is how to find its path? So I was doing

The file path to be opened is provided, how to get a handle to the new window?

不问归期 提交于 2019-12-11 15:04:55
问题 I want to implement a shell context menu "Open to Left/Right" that user can open a file with the new window being re-positioned to occupy the left/right half of the screen. Basically I just call Process.Start(fileName) , and get the process's MainWindowHandle , and pass the handle to SetWindowPos to set the window's position. But some applications (like Word) are running as singleton instance, so Process.Start("new.docx") just pass the file name to the running instance, and returns null , so

CFSTR_FILEDESCRIPTOR/CFSTR_FILECONTENTS 'Copying Files' Dialog missing

我与影子孤独终老i 提交于 2019-12-11 14:59:05
问题 I have a namespace extension that supports copy-paste using the CFSTR_FILEDESCRIPTOR/ CFSTR_FILECONTENTS to copy virtual files to the clipboard. However, the 'Copying Files...' progress dialog does not show up. Explorer appears to hang until the copy operation is complete. Any suggestions as to how to get the progress dialog to work? Thanks, Mridul. 回答1: Well... that was a straight forward fix... Ensure that for the FILEDESCRIPTOR object, FILEDESCRIPTOR.dwFlags |= FD_PROGRESSUI; Mridul. 来源:

Files created but, No data getting uploaded via using FTP in shell

限于喜欢 提交于 2019-12-11 13:25:42
问题 I am using command ftp -n -s:C:\FTP_cmd.txt ftp.madrecha.com the FTP_cmd.txt file contains user myName@domain.com Pa$$Word Put C:\AccessDocumentation.pptx quit The file is getting created on server. but, size is 0 bytes . No data in the file. I tried using FileZilla to upload same file using same user. That was successful and file was created with 352 KB Is there issue in the command or this is server side issue? PS: I tried running using cmd (on windows) and also on Powershell (on windows).

How do I programmatically open the “Libraries” folder in Windows Explorer in Windows 7?

只愿长相守 提交于 2019-12-11 12:38:17
问题 Note, the user may have redefined the default window for windows explorer, so simply opening "" using Process.Start or IShellDispatch.Open is not going to be acceptable. I figured this would be trivial, but I've lost a day trying to find an example. Note, the Libraries folder is a known folder with a folder id of FOLDERID_Libraries . Opening up using the associated GUID for FOLDERID_Libraries using Process.Start("explorer.exe", "::{1B3EA5DC-B587-4786-B4EF-BD1DC332AEAE}") opened "My Documents"

Is there a way to resolve a .lnk target that works for links that end up in c:\windows\installer?

孤人 提交于 2019-12-11 12:27:44
问题 The usual way to resolve lnk involve using WShell.WshShortcut or IShellLink that way : var WshShell = WScript.CreateObject("WScript.Shell"); var oShellLink = WshShell.CreateShortcut(strDesktop + "\\some-shortcut.lnk"); WScript.Echo(oShellLink.TargetPath) But there are links that can't be resolved that way : the resolution end up in c:\windows\installer\{some-guid}\python_icon.exe for example. Most Office programs have this issue too. CodeProject has another solution done by reverse