I need to set the default PDF reader to either Adobe Pro 2017 or Adobe Reader DC on Windows 10.
This needs to be set through the cmd line.
This needs to be done without needing to restart the machine?
Is this possible?
Regards,
John
cmd /c ftype /?
Try this
Here is a thread you can look at:
https://social.technet.microsoft.com/Forums/en-US/e4a0438a-6ef6-4dd8-b9cd-776fe2ec4ba8/setting-default-programs-in-windows-10-via-command-linepowershell
Related
I want to install license for my PC. However, I can't add parameter for the method.
My code:
#echo off
for /r "%SystemRoot%\system32\spp\tokens" %%f in (*.xrm-ms) DO (
wmic path SoftwareLicensingService WHERE (Version is not null) call InstallLicense License='<%%f'
)
pause
Like I want to read all text in the files of "tokens" directory and send it to License parameter.
Here is VB code. I can do it in VB but not in .bat file (Batch)
Dim files As String() = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.System) & "\spp\tokens", "*.xrm-ms", SearchOption.AllDirectories)
wmic = New ManagementObjectSearcher("SELECT Version FROM SoftwareLicensingService").Get()
For Each i As String In files
For Each wmi As ManagementObject In wmic
wmi.InvokeMethod("InstallLicense", {File.ReadAllText(i)})
Next
Next
Thanks all. Sorry for my bad English because I'm Chinese :(
At work we are constantly juggling multiple licenses of a software package. The license key is stored in the registry in HKEY_LOCAL_MACHINE so I wrote a Windows Batch File that when run as administrator, edits the registry key to one of the license strings.
Most recently I've written a GUI based application in VB.net that uses the software package's API to add some cool functionality. I also wanted to include a GUI based license switching module to make the juggling even easier. However, I haven't been able to succeed in doing so.
I've tried multiple methods, running the program as Administrator:
Using VB.Net's Registry module
Dim key As RegistryKey = Registry.LocalMachine
Dim autoshell As RegistryKey
autoshell = key.OpenSubKey(registryKeyDirectory, True)
autoshell.SetValue("Software", licenseKey)
autoshell.Close()
Running a .reg script
Dim p As New ProcessStartInfo
p.FileName = "regedit.exe"
p.UseShellExecute = True
p.Arguments = """C:\test.reg"""
Process.Start(p)
Sending the Registry edit command to CMD
Dim process As New Process()
process.StartInfo.FileName = "cmd.exe"
process.StartInfo.Verb = "runas"
process.StartInfo.UseShellExecute = True
process.StartInfo.Arguments = "/K reg add ""HKEY_LOCAL_MACHINE\SOFTWARE\Software\Licenses\Serial Numbers"" /f /v ""Software"" /t REG_SZ /d """ + licenseKey + """"
process.Start()
Running the Windows Batch Script through CMD in a similar way to above
'Code is much the same as above
All of these methods worked perfectly with editing a Key in HKEY_CURRENT_USER. I thought it might be the particular key and the permissions relating to it, but after further testing I found that none of the above code could edit any arbitrary key in HKEY_LOCAL_MACHINE.
I've looked at just about every link on Stack Overflow relating to this and no-one seems to be having the same problem as me. I suspected it might have to do with the privileges of my user account on the office network, so I took the code and tested it on my home PC but to no avail.
At this point I'm really at my wit's end and would greatly appreciate any help!
Thank you in advance for reading :)
This is caused by the Registry Redirector. (Noted: This link seems to be written in the win7 era and kind of outdated). Your program is 32-bit, when running on a 64-bit OS, the call to registry is redirected to the 32-bit logical view of the registry.
In Visual Studio, compile your program to target AnyCPU, also uncheck the "Prefer 32-bit" checkbox. Then the program would run as 64-bit on 64-bit OS, and 32-bit on 32-bit OS.
I need a way of downloading a program through either visual basic or cmd. I have tried these, but the file after it's downloaded is only about 600 bytes and doesn't work. I own this website and have ftp access, if I download it through ftp it's fine. I'm using Visual Studio 2013 by the way. These are the methods I've tried:
CMD through VB:
Dim MyCmd, Ws, Ret
Ws = CreateObject("wscript.Shell")
MyCmd = "cmd /c Powershell.exe -ExecutionPolicy bypass -noprofile -WindowStyle Hidden (New-Object System.Net.WebClient).DownloadFile('http://minecraftmapmakerstool.16mb.com/downloads/The_Map_Makers_Tool.exe','C:\Users\user\Desktop\The_Map_Makers_Tool.exe'); Start-Process C:\Users\user\Desktop\The_Map_Makers_Tool.exe;"
Ret = Ws.run(MyCmd, 0, True)
VB:
My.Computer.Network.DownloadFile("http://minecraftmapmakerstool.16mb.com/downloads/The_Map_Makers_Tool.exe", "C:\Users\user\Desktop\The_Map_Makers_Tool.exe")
Thanks in advance :)
I think there is no built in tool in Windows that would do that for you. But there are plenty free programs on the web, that you can install and then call from your batch script. Here is one of them: CURL
Here is a basic example of how to use it (using your link)
#echo Off
Title
Pause
CD C:\Users\Jah\desktop
curl http://www.jah.com/ofac/downloads/t11sdn.pdf > download.pdf
This would download and save the file from the URL you have provided to download.pdf
Another possible alternative would be WGET.
I am using ConEmu (robust cmd) on Windows 8 Pro.
How/where can I set conemu to run autostart_console.bat when starting ConEmu or when opening a new tab?
Thank you.
In most cases you need to use following command in Command line field (Settings -> Startup).
cmd /k autostart_console.bat
If you need to start other shell (not cmd.exe), for example Far Manager
cmd /c autostart_console.bat & far.exe
Full paths to autostart_console.bat or far.exe are required if they are not in %PATH%.
Is is possible to run cmd commands straight from VB. I want to be able to set up a command in vb without showing the black cmd window
path= C:\Program Files (x86)\Java\jre6\bin
java -Xmx1024M -Xms1024M -jar minecraft.jar nogui
Is it possible to run it without making a batch file? ( I want be be able to change some of the values in the commands to)
I found Shell(pathname[,windowstyle]) but I am not quite sure how to use it or if it is the right code.
You can use the Process class.
Dim pi As new ProcessStartInfo("C:\Program Files (x86)\Java\jre6\bin\java")
pi.Arguments = "-Xmx1024M -Xms1024M -jar minecraft.jar nogui"
Process.Start(pi)
I have use ProcessStartInfo to hold the process information before starting it off.
you can use Process.Start static Method
MSDN Link