Changing Drive Letters - vbscript

I'm having a little trouble figuring out how to use a root directory with a program for flash drives. For example: I'm trying to run "E://Program/data/install.vbs" but the driver letter keeps changing. Any help will be appreciated, thank you.
I think the batch version of what I am looking for is %root%\Program\data\install.bat but I still need it in vbscript form.

Try to "lock" the letter of flash drive in Computer Management is you are using Windows.

If you use Windows then go to Control Panel > Disk Management
Find your drive, right click, select "change drive latter and path", click on "add" browse to a new folder on your local computer [C:\MyFlashCard].
Every time you connect your flash drive, no matter which drive latter it gets, it will be mounted to the folder you selected, so you can use the local path. [c:\MyFlashDrive\program\data\install.vbs]

Related

one of my drives not showing in list of thisPC

I had 7 drives, but after formatting the windows one of that drive(I:) not showing, help me to retrive that drive without loosing any data
I think your drive is unmounted
https://www.isunshare.com/windows-10/add-a-hard-drive-to-this-pc-in-windows-10.html
your drive might missing the Drive Letter or path please follow the bellow method to assign a new letter
click on windows
search drive management ( click on "Create or format hard disk partition")
right click on your missing drive and select "Change Drive letter and path"
click on "Add"
select any one of the given letter
click ok
check the drive in this pc
tada, drive retrived with all data
OR
If your drive is unmounted follow those steps: https://www.tech-recipes.com/rx/58667/mount-drive-windows/

Autorun USB in Windows 10?

How could I get an autorun USB drive in Windows 7/8/10. autorun.inf doesn't seem to work anymore. Also could this work without any rubber duckie USB drives? Maybe trick windows into thinking it is a DVD or CD to autorun?
If you mean AutoPlay, you can set it up like this:
Open Control Panel and navigate to 'Hardware And Sound' > 'AutoPlay'.
Find the 'Removable Drive' option.
Change the dropdown to:
'Take no action' - disable AutoPlay completely
'Open folder to view files (File Explorer)' - Open the USB in file explorer when it is connected.
'Ask me every time' - Show a program chooser: most likely what you want.
you might need to change a windows registry entry to allow media to be run automatically so that the autorun.inf file can be executed once the device is plugged in
[autorun]
Icon=lock.ico
Label=Payroll Information
;Open=FetchSalariesDB.EXE
ShellExecute=FetchSalariesDB.EXE
UseAutoPlay=1
Yes, there is a way,
to do this you have to convert your USB into "NTFS" normally its "FAT32"
To do this, find your USB drive on your computer
https://i.stack.imgur.com/DkFOK.png -- Image (just my USB drive)
Then right-click on that USB drive. Then click on "Change Format" or "Format" https://i.stack.imgur.com/42yLK.png -- Picture of that. Then click and change it to "NTFS" instead of "FAT32" https://i.stack.imgur.com/ziA67.png -- And another picture of that. Then all you have to do from here is making a regular autorun.inf file and it will autorun whatever you desire, and it even works without the permission from "AutoPlay" Have fun :)

Windows: How to symlink drive to another drive?

I have a client whose data has been moved from the H drive to the I drive, but their Access export script seems to have hardcoded the H drive as the destination even though it no longer exists on the new system. How would I create an H drive that maps to the I drive? I'm a unix/linux guy.
I'm guessing something like mklink /d H: I:? Would that work?
No, mklink isn't going to do it for you. What you need to do is to create a virtual hard drive (VHD) and copy the client's data to it. (Or modify the export script, which is the best thing to do.) I used Windows 7 to test my instructions below.
Start-> run-> diskmgmt.msc (accept all defaults... I'm not doing anything special below)
From the menu bar select Action -> Create VHD
Choose the location and name the file (which will be the vhd) and specify the size and click OK.
Right click on the Disk # (underneath will be Unknown and the size and "Not Initialized"). Select "Initialize Disk" & click OK
Right click on the black bar of the unallocated disk space and select "new simple volume". A wizard opens up an on the second page it lets you assign the drive letter. Complete the wizard and you're done!
You can use good old SUBST command for that
"subst H: I:"
Create some startup CMD to make it available after reboot.
Map a network drive to \\localhost\H$ and set it to Drive I.

Opening a CHM file produces: "navigation to the webpage was canceled"

I am trying to open a .chm file.
I downloaded the source, extracted it, and double clicked on Waffle.chm and clicked "Open" but no matter what element in the chm file I click, I get the message:
Navigation to the webpage was canceled.
What you can try:
Retype the address.
What's going on here?
Summary
Microsoft Security Updates 896358 & 840315 block display of CHM file contents when opened from a network drive (or a UNC path). This is Windows' attempt to stop attack vectors for viruses/malware from infecting your computer and has blocked out the .chm file that draw data over the "InfoTech" protocol, which this chm file uses.
Microsoft's summary of the problem: http://support.microsoft.com/kb/896054
Solutions
If you are using Windows Server 2008, Windows 7, windows has created a quick fix. Right click the chm file, and you will get the "yourfile.chm Properties" dialog box, at the bottom, a button called "Unblock" appears. Click Unblock and press OK, and try to open the chm file again, it works correctly. This option is not available for earlier versions of Windows before WindowsXP (SP3).
Solve the problem by moving your chm file OFF the network drive. You may be unaware you are using a network drive, double check now: Right click your .chm file, click properties and look at the "location" field. If it starts with two backslashes like this: \\epicserver\blah\, then you are using a networked drive. So to fix it, Copy the chm file, and paste it into a local drive, like C:\ or E:. Then try to reopen the chm file, windows does not freak out.
Last resort, if you can't copy/move the file off the networked drive. If you must open it where it sits, and you are using a lesser version of windows like XP, Vista, ME or other, you will have to manually tell Windows not to freak out over this .chm file. HHReg (HTML Help Registration Utility) Utility Automates this Task. Basically you download the HHReg utility, load your .chm file, press OK, and it will create the necessary registry keys to tell Windows not to block it. For more info: http://www.winhelponline.com/blog/fix-cannot-view-chm-files-network-xp-2003-vista/
Windows 8 or 10? --> Upgrade to Windows XP.
"unblocking" the file fixes the problem. Screenshot:
Win 8 x64:
just move it to another folder or rename your folder (in my case: my folder was "c#").
avoid to use symbol on folder name. name it with letter.
done.
In addition to Eric Leschinski's answer, and because this is stackoverflow, a programmatical solution:
Windows uses hidden file forks to mark content as "downloaded". Truncating these unblocks the file. The name of the stream used for CHM's is "Zone.Identifier". One can access streams by appending :streamname when opening the file. (keep backups the first time, in case your RTL messes that up!)
In Delphi it would look like this:
var f : file;
begin
writeln('unblocking ',s);
assignfile(f,'some.chm:Zone.Identifier');
rewrite(f,1);
truncate(f);
closefile(f);
end;
I'm told that on non forked filesystems (like FAT32) there are hidden files, but I haven't gotten to the bottom of that yet.
P.s. Delphi's DeleteFile() should also recognize forks.
The definitive solution is to allow the InfoTech protocol to work in the intranet zone.
Add the following value to the registry and the problem should be solved:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp\1.x\ItssRestrictions]
"MaxAllowedZone"=dword:00000001
More info here: http://support.microsoft.com/kb/896054
Go to Start
Type regsvr32 hhctrl.ocx
You should get a success message like:
" DllRegisterServer in hhctrl.ocx succeeded "
Now try to open your CHM file again.
other way is to use different third party software. This link shows more third party software to view chm files...
I tried with SumatraPDF and it work fine.
I fixed this programmatically in my software, using C++ Builder.
Before I assign the CHM help file, Application->HelpFile = HelpFileName, I check to see if it contains the "Zone.Identifier" stream, and when it does, I simply remove it.
String ZIStream(HelpFileName + ":Zone.Identifier") ;
if (FileExists(ZIStream))
{ DeleteFile(ZIStream) ; }
There are apparently different levels of authentication. Most articles I read tell you to set the MaxAllowedZone to '1' which means that local machine zone and intranet zone are allowed but '4' allows access for 'all' zones.
For more info, read this article:
https://support.microsoft.com/en-us/kb/892675
This is how my registry looks (I wasn't sure it would work with the wild cards but it seems to work for me):
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp\1.x]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp\1.x\ItssRestrictions]
"MaxAllowedZone"=dword:00000004
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp\1.x\ItssRestrictions]
"UrlAllowList"="\\\\<network_path_root>;\\\\<network_path_root>\*;\\ies-inc.local;http://www.*;http://*;https://www.*;https://*;"
As an additional note, weirdly the "UrlAllowList" key was required to make this work on another PC but not my test one. It's probably not required at all but when I added it, it fixed the problem. The user may have not closed the original file or something like that. So just a consideration. I suggest try the least and test it, then add if needed. Once you confirm, you can deploy if needed. Good Luck!
Edit: P.S. Another method that worked was mapping the path to the network locally by using mklink /d (symbolic linking in Windows 7 or newer) but mapping a network drive letter (Z: for testing) did not work. Just food for thought and I did not have to 'Unblock' any files. Also the accepted 'Solution' did not resolve the issue for me.
Moving to local folder is the quickest solution, nothing else worked for me esp because I was not admin on my system (can't edit registery etc), which is a typical case in a work environment.
Create a folder in C:\help drive, lets call it help and copy the files there and open.
Do not copy to mydocuments or anywhere else, those locations are usually on network drive in office setup and will not work.

External Drive Letter - Backup

I am writing a PowerShell script that will back up several folders from my Vista drive to an external USB drive, using robocopy.
Windows does not guarantee that it will always assign the same drive letter to the external drive.
What is the best way to get around this problem?
How do I code the destination paths?
Thanks.
Windows could change that drive letter assigned to your USB drive.
The correct way to do this backup is mounting the USB drive in an empty directory. Not only does it add some consistency to swapped storage, it also allows for a persistent shortcut on a Windows desktop.
That's how to:
Run "diskmgmt.msc" from Windows' Run/Start Search box,
Right-click on your plugged-in drive and choose "Change Drive Letter
and Paths."
Remove the current drive letter assigned to your drive.
Click on the Add button
Select Mount into the following empty NTFS folder and click on
browse.
Now navigate to the subfolder that you want to assign the USB drive
to and confirm the assignment.
The USB drive will from now on be accessible from that folder (if it is connected to the computer of course).
Now you can change your script to select, as destination folder, the folder with the mounted drive and forget the drive letter persistence.
Use can use "Drive Letter View" available free at http://www.nirsoft.net/utils/drive_letter_view.html to assign desired drive letter to external drive. From this moment on, the selected removable media will always be mounted with same letter. (Test with windows 8.1)
Towards commercial side "Zentimo storage" at http://www.zentimo.com is the best solution.
or
Use Diskpart
diskpart> list volume
select volume n
assign letter=T i.e the new letter.
Are you sure it's impossible? (I don't have an external hard drive to test now). I think that if you right-click on "computer", then select manage, you can select a letter for an hard drive that will allways be the same for this disk.
However, can't you use the serial number of the disk?
(sorry if my explanations weren't well explained, I'm not a native english speaker)

Resources